Skip to content

Commit 86db495

Browse files
committed
context menu: take the mouse position into account
1 parent aafc85e commit 86db495

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

git-blame.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,21 @@ def on_phantom_close(self, href):
175175
else:
176176
self.view.erase_phantoms('git-blame')
177177

178-
def run(self, edit):
178+
def want_event(self):
179+
return True
180+
181+
def run(self, edit, event=None):
179182
if not view_is_suitable(self.view):
180183
return
181184

185+
if event:
186+
# This command was ran from the context menu. Before proceeding,
187+
# move the caret to where the mouse was clicked.
188+
mouse_position = (event["x"], event["y"])
189+
text_point = self.view.window_to_text(mouse_position)
190+
self.view.sel().clear()
191+
self.view.sel().add(sublime.Region(text_point))
192+
182193
phantoms = []
183194
self.view.erase_phantoms('git-blame')
184195
# Before adding the phantom, see if the current phantom that is displayed is at the same spot at the selection

0 commit comments

Comments
 (0)