Skip to content

BlameShowAll ergonomics #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[
{
"keys": ["ctrl+alt+b"],
"command": "blame"
}
{"keys": ["ctrl+alt+b"], "command": "blame"},
{"keys": ["ctrl+alt+shift+b"], "command": "blame_show_all"}
]
6 changes: 2 additions & 4 deletions Default (Windows).sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[
{
"keys": ["ctrl+alt+b"],
"command": "blame"
}
{"keys": ["ctrl+alt+b"], "command": "blame"},
{"keys": ["ctrl+alt+shift+b"], "command": "blame_show_all"}
]
12 changes: 10 additions & 2 deletions git-blame.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def run(self, edit):
if self.phantom_set.phantoms and self.view.line(self.view.sel()[0]) == self.view.line(self.phantom_set.phantoms[0].region):
self.phantom_set.update(phantoms)
return

for region in self.view.sel():
line = self.view.line(region)
(row, col) = self.view.rowcol(region.begin())
Expand Down Expand Up @@ -217,13 +217,19 @@ def run(self, edit):
return

self.view.erase_phantoms(PHANTOM_KEY_ALL)
phantoms = []

# If they are currently shown, toggle them off and return.
if self.view.settings().get(SETTING_PHANTOM_ALL_DISPLAYED, False):
self.phantom_set.update(phantoms)
self.view.settings().set(SETTING_PHANTOM_ALL_DISPLAYED, False)
return

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

if not blame_lines:
return

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

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

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