Skip to content

Commit a61e3e4

Browse files
froupsykzz
authored andcommitted
BlameShowAll ergonomics (#22)
* Allow blame_show_all to toggle, like regular blame * Give blame_show_all a keybinding * Fix blame_show_all interaction with horiz scroll
1 parent 61149d8 commit a61e3e4

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

Default (OSX).sublime-keymap

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
[
2-
{
3-
"keys": ["ctrl+alt+b"],
4-
"command": "blame"
5-
}
2+
{"keys": ["ctrl+alt+b"], "command": "blame"},
3+
{"keys": ["ctrl+alt+shift+b"], "command": "blame_show_all"}
64
]

Default (Windows).sublime-keymap

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
[
2-
{
3-
"keys": ["ctrl+alt+b"],
4-
"command": "blame"
5-
}
2+
{"keys": ["ctrl+alt+b"], "command": "blame"},
3+
{"keys": ["ctrl+alt+shift+b"], "command": "blame_show_all"}
64
]

git-blame.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,19 @@ def run(self, edit):
217217
return
218218

219219
self.view.erase_phantoms(PHANTOM_KEY_ALL)
220+
phantoms = []
221+
222+
# If they are currently shown, toggle them off and return.
223+
if self.view.settings().get(SETTING_PHANTOM_ALL_DISPLAYED, False):
224+
self.phantom_set.update(phantoms)
225+
self.view.settings().set(SETTING_PHANTOM_ALL_DISPLAYED, False)
226+
return
220227

221228
blame_lines = self.get_blame_lines(self.view.file_name())
222229

223230
if not blame_lines:
224231
return
225232

226-
phantoms = []
227233
for l in blame_lines:
228234
parsed = self.parse_blame(l)
229235
if not parsed:
@@ -246,6 +252,8 @@ def run(self, edit):
246252

247253
self.phantom_set.update(phantoms)
248254
self.view.settings().set(SETTING_PHANTOM_ALL_DISPLAYED, True)
255+
# Bring the phantoms into view without the user needing to manually scroll left.
256+
self.view.set_viewport_position((0.0, self.view.viewport_position()[1]))
249257

250258
def get_blame_lines(self, path):
251259
'''Run `git blame` and get the output lines.

0 commit comments

Comments
 (0)