Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds jumping to previous and next changes.

- Adds two new commands: "git_gutter_next_change" and "git_gutter_previous_change"
  • Loading branch information...
commit 2c89ae6fa0a6cf9c9479f2a91c766fc37086fe9c 1 parent 0f9908b
@DavidLGoldberg DavidLGoldberg authored
Showing with 33 additions and 0 deletions.
  1. +33 −0 git_gutter.py
View
33 git_gutter.py
@@ -20,6 +20,39 @@ def plugin_loaded():
makedirs(icon_path)
+def move_to_change(window, direction):
+ view = window.active_view()
+
+ inserted, modified, deleted = ViewCollection.diff(view)
+ all_changes = sorted(inserted + modified + deleted)
+
+ row, col = view.rowcol(view.sel()[0].begin())
+
+ try:
+ if direction == "next":
+ line = next(change for change in all_changes
+ if change > row + 1)
+ else:
+ line = next(change for change in reversed(all_changes)
+ if change < row + 1)
+
+ window.active_view().run_command("goto_line", {"line": line})
+ except:
+ pass
+
+
+class GitGutterNextChangeCommand(sublime_plugin.WindowCommand):
+
+ def run(self):
+ move_to_change(self.window, "next")
+
+
+class GitGutterPreviousChangeCommand(sublime_plugin.WindowCommand):
+
+ def run(self):
+ move_to_change(self.window, "previous")
+
+
class GitGutterCommand(sublime_plugin.WindowCommand):
def run(self):
Please sign in to comment.
Something went wrong with that request. Please try again.