Skip to content

Commit 280912d

Browse files
committed
Graph/blame: support multi-select when opening commits
1 parent 47a3228 commit 280912d

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

git/history.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -255,29 +255,30 @@ def show_done(self, result):
255255
class GitGotoCommit(GitTextCommand):
256256
def run(self, edit):
257257
view = self.view
258-
selection = view.sel()[0]
259-
if not (
260-
self.view.match_selector(selection.a, "text.git-blame")
261-
or self.view.match_selector(selection.a, "text.git-graph")
262-
):
263-
return
264258

265259
# Sublime is missing a "find scope in region" API, so we piece one together here:
266-
line = view.line(view.sel()[0].a)
260+
lines = [view.line(sel.a) for sel in view.sel()]
267261
hashes = self.view.find_by_selector("string.sha")
268-
commit = False
262+
commits = []
269263
for region in hashes:
270-
if line.contains(region):
271-
commit = view.substr(region)
272-
break
273-
if not commit or commit.strip("0") == "":
274-
return
264+
for line in lines:
265+
if line.contains(region):
266+
commit = view.substr(region)
267+
if commit.strip("0"):
268+
commits.append(commit)
269+
break
270+
275271
working_dir = view.settings().get("git_root_dir")
276-
self.run_command(['git', 'show', commit], self.show_done, working_dir=working_dir)
272+
for commit in commits:
273+
self.run_command(['git', 'show', commit], self.show_done, working_dir=working_dir)
277274

278275
def show_done(self, result):
279276
self.scratch(result, title="Git Commit View",
280277
syntax=plugin_file("syntax/Git Commit View.tmLanguage"))
281278

282279
def is_enabled(self):
283-
return True
280+
selection = self.view.sel()[0]
281+
return (
282+
self.view.match_selector(selection.a, "text.git-blame")
283+
or self.view.match_selector(selection.a, "text.git-graph")
284+
)

0 commit comments

Comments
 (0)