Skip to content

Commit 2742789

Browse files
authored
Merge pull request #20 from gh640/19-prevent-too-much-erase-all
Clear the issue #19
2 parents 2d530c1 + 14ac20a commit 2742789

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

git-blame.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from subprocess import check_output as shell
88

99
PHANTOM_KEY_ALL = 'git-blame-all'
10+
SETTING_PHANTOM_ALL_DISPLAYED = 'git-blame-all-displayed'
1011

1112
stylesheet_one = '''
1213
<style>
@@ -244,6 +245,7 @@ def run(self, edit):
244245
phantoms.append(phantom)
245246

246247
self.phantom_set.update(phantoms)
248+
self.view.settings().set(SETTING_PHANTOM_ALL_DISPLAYED, True)
247249

248250
def get_blame_lines(self, path):
249251
'''Run `git blame` and get the output lines.
@@ -330,10 +332,17 @@ def run(self, edit):
330332

331333
class BlameEraseAllListener(sublime_plugin.ViewEventListener):
332334

333-
def on_modified(self):
335+
@classmethod
336+
def is_applicable(cls, settings):
337+
'''Checks if the blame_erase_all command is applicable.
338+
'''
339+
return settings.get(SETTING_PHANTOM_ALL_DISPLAYED, False)
340+
341+
def on_modified_async(self):
334342
'''Automatically erases the blame results to prevent mismatches.
335343
'''
336344
self.view.run_command('blame_erase_all')
345+
self.view.settings().erase(SETTING_PHANTOM_ALL_DISPLAYED)
337346

338347

339348
class InsertCommitDescriptionCommand(sublime_plugin.TextCommand):

0 commit comments

Comments
 (0)