Skip to content

Commit

Permalink
Merge pull request #1827 from timbrel/navigation-nits
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste authored Dec 8, 2023
2 parents 37dc7a7 + 4fa5cb8 commit 31c8b4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/commands/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ class gs_diff_navigate(GsNavigate):
"""

offset = 0
wrap_with_force = True
log_position = True

def get_available_regions(self):
return [
Expand Down
1 change: 1 addition & 0 deletions core/commands/inline_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,7 @@ class gs_inline_diff_navigate_hunk(GsNavigate):
position.
"""
offset = 0
log_position = True
first_region_may_expand_to_bof = False

def get_available_regions(self):
Expand Down
12 changes: 8 additions & 4 deletions core/commands/navigate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from sublime_plugin import TextCommand

from ..git_command import GitCommand
from ..utils import flash
from GitSavvy.core.view import show_region


Expand All @@ -19,6 +20,7 @@ class GsNavigate(TextCommand, GitCommand):
show_at_center = False
wrap = True
wrap_with_force = False
log_position = False
# For the first entry, try to show the beginning of the buffer.
# (Usually we have some info/help text there.)
first_region_may_expand_to_bof = True
Expand All @@ -28,7 +30,7 @@ class GsNavigate(TextCommand, GitCommand):
def run(self, edit, forward=True):
self.forward = forward
sel = self.view.sel()
current_position = sel[0].a
current_position = sel[0].b

available_regions = self.get_available_regions()
if not available_regions:
Expand All @@ -41,12 +43,14 @@ def run(self, edit, forward=True):
)
if wanted_section is None:
if self._just_jumped == 1:
window = self.view.window()
if window:
window.status_message("press again to wrap around ...")
flash(self.view, "press again to wrap around ...")
self._just_jumped -= 1
return

if self.log_position:
idx = available_regions.index(wanted_section)
flash(self.view, f"[{idx + 1}/{len(available_regions)}]")

self._just_jumped = 2
sel.clear()
# Position the cursor at the beginning of the section...
Expand Down

0 comments on commit 31c8b4f

Please sign in to comment.