Skip to content

Commit 58efaaa

Browse files
committed
go_back command takes previous column into account
fixed typo in messages.json
1 parent 7136375 commit 58efaaa

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

messages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"install": "messages/install.txt",
33
"1.0.3": "messages/1.0.3.txt"
4-
} "1.0.3": "messages/1.0.3.txt"
4+
}

sublime_python_commands.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,29 +146,31 @@ def run(self, *args):
146146
return
147147

148148
target_path, target_lineno = def_result
149-
current_lineno = view.rowcol(view.sel()[0].end())[0] + 1
149+
current_rowcol = view.rowcol(view.sel()[0].end())
150+
current_lineno = current_rowcol[0] + 1
151+
current_colno = current_rowcol[1] + 1
150152

151153
if None not in (path, target_path, target_lineno):
152-
self.save_pos(file_or_buffer_name(view), current_lineno)
154+
self.save_pos(file_or_buffer_name(view), current_lineno, current_colno)
153155
path = target_path + ":" + str(target_lineno)
154156
self.window.open_file(path, sublime.ENCODED_POSITION)
155157
elif target_lineno is not None:
156-
self.save_pos(file_or_buffer_name(view), current_lineno)
158+
self.save_pos(file_or_buffer_name(view), current_lineno, current_colno)
157159
path = file_or_buffer_name(view) + ":" + str(target_lineno)
158160
self.window.open_file(path, sublime.ENCODED_POSITION)
159161
else:
160162
# fail silently (user selected whitespace, etc)
161163
pass
162164

163-
def save_pos(self, file_path, lineno):
164-
GOTO_STACK.append((file_path, lineno))
165+
def save_pos(self, file_path, lineno, colno=0):
166+
GOTO_STACK.append((file_path, lineno, colno))
165167

166168

167169
class PythonGoBackCommand(sublime_plugin.WindowCommand):
168170

169171
@python_only
170172
def run(self, *args):
171173
if GOTO_STACK:
172-
file_name, lineno = GOTO_STACK.pop()
173-
path = file_name + ":" + str(lineno)
174+
file_name, lineno, colno = GOTO_STACK.pop()
175+
path = "%s:%d:%d" % (file_name, lineno, colno)
174176
self.window.open_file(path, sublime.ENCODED_POSITION)

0 commit comments

Comments
 (0)