Skip to content

Commit

Permalink
Pin viewport's x-axis to 0 after navigate
Browse files Browse the repository at this point in the history
Sometimes navigation scrolls to the right, allways scroll back to left.
  • Loading branch information
stoivo committed Jul 6, 2019
1 parent 3f8dc3d commit bffa311
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/commands/navigate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ def run(self, edit, forward=True):
# Position the cursor at the beginning of the file name.
new_position += self.offset
sel.add(sublime.Region(new_position, new_position))
self.view.run_command("show_at_center")
self.view.show_at_center(new_position)

# The following shouldn't strictly be necessary, but Sublime sometimes
# jumps to the right when show_at_center for a column-zero-point occurs.
_, vp_y = self.view.viewport_position()
self.view.set_viewport_position((0, vp_y), False)

def forward(self, current_position, file_regions):
for file_region in file_regions:
Expand Down

0 comments on commit bffa311

Please sign in to comment.