get the reverse tokenizer positions right even with strange docstring situations

This commit is contained in:
David Halter
2013-07-26 01:24:44 +02:00
parent 284f2f1671
commit 8598fe7327
2 changed files with 8 additions and 6 deletions

View File

@@ -122,7 +122,7 @@ class ModuleWithCursor(Module):
def get_path_until_cursor(self): def get_path_until_cursor(self):
""" Get the path under the cursor. """ """ Get the path under the cursor. """
result = self._get_path_until_cursor() result = self._get_path_until_cursor()
self._start_cursor_pos = self._line_temp + 1, self._column_temp self._start_cursor_pos = self._last_tok_line, self._column_temp
return result return result
def _get_path_until_cursor(self, start_pos=None): def _get_path_until_cursor(self, start_pos=None):
@@ -139,6 +139,7 @@ class ModuleWithCursor(Module):
while True: while True:
self._line_temp -= 1 self._line_temp -= 1
last_line = self.get_line(self._line_temp) last_line = self.get_line(self._line_temp)
#print self._line_temp, repr(last_line)
if last_line and last_line[-1] == '\\': if last_line and last_line[-1] == '\\':
line = last_line[:-1] + ' ' + line line = last_line[:-1] + ' ' + line
self._line_length = len(last_line) self._line_length = len(last_line)
@@ -147,11 +148,8 @@ class ModuleWithCursor(Module):
return line[::-1] return line[::-1]
self._is_first = True self._is_first = True
if start_pos is None: self._line_temp, self._column_temp = start_pos or self.position
self._line_temp = self.position[0] self._last_tok_line = self.position[0]
self._column_temp = self.position[1]
else:
self._line_temp, self._column_temp = start_pos
open_brackets = ['(', '[', '{'] open_brackets = ['(', '[', '{']
close_brackets = [')', ']', '}'] close_brackets = [')', ']', '}']
@@ -191,6 +189,7 @@ class ModuleWithCursor(Module):
self._column_temp = self._line_length - end[1] self._column_temp = self._line_length - end[1]
break break
self._last_tok_line = self.position[0] - end[0] + 1
self._column_temp = self._line_length - end[1] self._column_temp = self._line_length - end[1]
string += tok string += tok
last_type = token_type last_type = token_type

View File

@@ -209,6 +209,9 @@ def a():
""" """
pass pass
#?
# str literals in comment """ upper
# ----------------- # -----------------
# magic methods # magic methods
# ----------------- # -----------------