@@ -18,6 +18,22 @@ class BlameInlineListener(BaseBlame, sublime_plugin.ViewEventListener):
18
18
19
19
pkg_setting_callback_added = False
20
20
21
+ # Overrides begin ------------------------------------------------------------------
22
+
23
+ def __init__ (self , view ):
24
+ super ().__init__ (view )
25
+ self .phantom_set = sublime .PhantomSet (view , INLINE_BLAME_PHANTOM_SET_KEY )
26
+ self .timer = None
27
+ self .delay_seconds = (
28
+ pkg_settings ().get (PKG_SETTINGS_KEY_INLINE_BLAME_DELAY ) / 1000
29
+ )
30
+ # Show it immediately for the initially selected line.
31
+ self .show_inline_blame ()
32
+
33
+ def run (self , edit ):
34
+ # Unlike the other BaseBlame subclasses, we are reactive, not a sublime_plugin.Command
35
+ pass
36
+
21
37
@classmethod
22
38
def is_applicable (cls , view_settings ):
23
39
if not cls .pkg_setting_callback_added :
@@ -29,6 +45,27 @@ def is_applicable(cls, view_settings):
29
45
30
46
return cls .determine_enablement (view_settings )
31
47
48
+ def on_selection_modified_async (self ):
49
+ self .show_inline_blame_handler ()
50
+
51
+ def on_post_save_async (self ):
52
+ # Redisplay the blame after the file is saved, because there will be
53
+ # no call to on_selection_modified_async after save.
54
+ self .show_inline_blame_handler ()
55
+
56
+ def extra_cli_args (self , line_num ):
57
+ args = ["-L" , "{0},{0}" .format (line_num ), "--date=relative" ]
58
+ return args
59
+
60
+ def _view (self ):
61
+ return self .view
62
+
63
+ def handle_phantom_close_button (self ):
64
+ # Inline Blame phantoms close automatically when appropriate.
65
+ pass
66
+
67
+ # Overrides end --------------------------------------------------------------------
68
+
32
69
@classmethod
33
70
def determine_enablement (cls , view_settings ):
34
71
enabled = view_settings .get (
@@ -61,30 +98,12 @@ def on_pkg_setting_changed(cls):
61
98
view .settings ().set (cls .__name__ , "" )
62
99
view .settings ().erase (cls .__name__ )
63
100
64
- def __init__ (self , view ):
65
- super ().__init__ (view )
66
- self .phantom_set = sublime .PhantomSet (view , INLINE_BLAME_PHANTOM_SET_KEY )
67
- self .timer = None
68
- self .delay_seconds = (
69
- pkg_settings ().get (PKG_SETTINGS_KEY_INLINE_BLAME_DELAY ) / 1000
70
- )
71
- # Show it immediately for the initially selected line.
72
- self .show_inline_blame ()
73
-
74
- def extra_cli_args (self , line_num ):
75
- args = ["-L" , "{0},{0}" .format (line_num ), "--date=relative" ]
76
- return args
77
-
78
- def _view (self ):
79
- return self .view
80
-
81
- def handle_phantom_close_button (self ):
82
- # Inline Blame phantoms close automatically when appropriate.
83
- pass
84
-
85
- def run (self , edit ):
86
- # Unlike the other BaseBlame subclasses, we are reactive, not a sublime_plugin.Command
87
- pass
101
+ def show_inline_blame_handler (self ):
102
+ self .view .erase_phantoms (INLINE_BLAME_PHANTOM_SET_KEY )
103
+ if self .timer :
104
+ self .timer .cancel ()
105
+ self .timer = threading .Timer (self .delay_seconds , self .show_inline_blame )
106
+ self .timer .start ()
88
107
89
108
def show_inline_blame (self ):
90
109
if self .view .is_dirty ():
@@ -145,21 +164,6 @@ def maybe_insert_phantoms(self, phantoms):
145
164
if not self .view .is_dirty ():
146
165
self .phantom_set .update (phantoms )
147
166
148
- def show_inline_blame_handler (self ):
149
- self .view .erase_phantoms (INLINE_BLAME_PHANTOM_SET_KEY )
150
- if self .timer :
151
- self .timer .cancel ()
152
- self .timer = threading .Timer (self .delay_seconds , self .show_inline_blame )
153
- self .timer .start ()
154
-
155
- def on_selection_modified_async (self ):
156
- self .show_inline_blame_handler ()
157
-
158
- def on_post_save_async (self ):
159
- # Redisplay the blame after the file is saved, because there will be
160
- # no call to on_selection_modified_async after save.
161
- self .show_inline_blame_handler ()
162
-
163
167
164
168
class ToggleInlineGitBlame (sublime_plugin .TextCommand ):
165
169
0 commit comments