@@ -18,13 +18,23 @@ def __init__(self, view):
18
18
super ().__init__ (view )
19
19
self .phantom_set = sublime .PhantomSet (view , "git-blame" )
20
20
21
- def run (self , edit , sha_skip_list = [], prevving = False ):
21
+ def run (self , edit , prevving = False , fixed_row_num = None , sha_skip_list = [] ):
22
22
if not view_is_suitable (self .view ):
23
23
return
24
24
25
25
phantoms = []
26
26
27
- for region in self .view .sel ():
27
+ if prevving :
28
+ # We'll be getting blame information for the line whose existing phantom's
29
+ # [Prev] button was clicked, regardless of where the text cursor(s)
30
+ # currently are.
31
+ relevant_regions = [sublime .Region (self .view .text_point (fixed_row_num , 0 ))]
32
+ else :
33
+ # We'll be getting blame information for the lines where text cursor(s)
34
+ # currently are.
35
+ relevant_regions = self .view .sel ()
36
+
37
+ for region in relevant_regions :
28
38
line_region = self .view .line (region )
29
39
30
40
# When this Command is ran for a line with a phantom already visible, we
@@ -35,12 +45,13 @@ def run(self, edit, sha_skip_list=[], prevving=False):
35
45
if self .phantom_exists_for_region (line_region ) and not prevving :
36
46
continue
37
47
38
- (row , _ ) = self .view .rowcol (region .begin ())
39
- line = row + 1
48
+ row_num , _ = self .view .rowcol (region .begin ())
49
+ line_num = row_num + 1
50
+
40
51
full_path = self .view .file_name ()
41
52
42
53
try :
43
- blame_output = self .get_blame (line , full_path , sha_skip_list )
54
+ blame_output = self .get_blame (line_num , full_path , sha_skip_list )
44
55
except Exception as e :
45
56
communicate_error (e )
46
57
return
@@ -67,6 +78,7 @@ def run(self, edit, sha_skip_list=[], prevving=False):
67
78
user = user ,
68
79
date = date ,
69
80
time = time ,
81
+ qs_row_num_val = quote_plus (str (row_num )),
70
82
qs_sha_val = quote_plus (sha_normalised ),
71
83
# Querystrings can contain the same key multiple times. We use that
72
84
# functionality to accumulate a list of SHAs to skip over when
@@ -153,10 +165,16 @@ def handle_phantom_button(self, href):
153
165
)
154
166
elif url .path == "prev" :
155
167
sha = querystring ["sha" ][0 ]
168
+ row_num = querystring ["row_num" ][0 ]
156
169
sha_skip_list = querystring .get ("skip" , [])
157
170
if sha not in sha_skip_list :
158
171
sha_skip_list .append (sha )
159
- self .run (None , sha_skip_list , prevving = True )
172
+ self .run (
173
+ None ,
174
+ prevving = True ,
175
+ fixed_row_num = int (row_num ),
176
+ sha_skip_list = sha_skip_list ,
177
+ )
160
178
elif url .path == "close" :
161
179
# Erase all phantoms
162
180
self .phantom_set .update ([])
0 commit comments