Skip to content

Commit ded2336

Browse files
committed
When run is called, check if the selection is at the same line as the last call, if so, hide the phantom
1 parent 03519f9 commit ded2336

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

git-blame.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -177,22 +177,23 @@ def on_phantom_close(self, href):
177177
def run(self, edit):
178178
phantoms = []
179179
self.view.erase_phantoms('git-blame')
180-
181-
for region in self.view.sel():
182-
line = self.view.line(region)
183-
(row, col) = self.view.rowcol(region.begin())
184-
full_path = self.view.file_name()
185-
result = self.get_blame(int(row) + 1, full_path)
186-
if not result:
187-
# Unable to get blame
188-
return
189-
190-
sha, user, date, time = self.parse_blame(result)
191-
192-
body = template_one.format(sha=sha, user=user, date=date, time=time, stylesheet=stylesheet_one)
193-
194-
phantom = sublime.Phantom(line, body, sublime.LAYOUT_BLOCK, self.on_phantom_close)
195-
phantoms.append(phantom)
180+
#Before adding the phantom, see if the current phantom that is displayed is at the same spot at the selection
181+
if not (self.phantom_set.phantoms and self.view.line(self.view.sel()[0]) == self.view.line(self.phantom_set.phantoms[0].region)):
182+
for region in self.view.sel():
183+
line = self.view.line(region)
184+
(row, col) = self.view.rowcol(region.begin())
185+
full_path = self.view.file_name()
186+
result = self.get_blame(int(row) + 1, full_path)
187+
if not result:
188+
# Unable to get blame
189+
return
190+
191+
sha, user, date, time = self.parse_blame(result)
192+
193+
body = template_one.format(sha=sha, user=user, date=date, time=time, stylesheet=stylesheet_one)
194+
195+
phantom = sublime.Phantom(line, body, sublime.LAYOUT_BLOCK, self.on_phantom_close)
196+
phantoms.append(phantom)
196197
self.phantom_set.update(phantoms)
197198

198199

0 commit comments

Comments
 (0)