@@ -18,13 +18,23 @@ def __init__(self, view):
1818 super ().__init__ (view )
1919 self .phantom_set = sublime .PhantomSet (view , "git-blame" )
2020
21- def run (self , edit , sha_skip_list = [], prevving = False ):
21+ def run (self , edit , prevving = False , fixed_row_num = None , sha_skip_list = [] ):
2222 if not view_is_suitable (self .view ):
2323 return
2424
2525 phantoms = []
2626
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 :
2838 line_region = self .view .line (region )
2939
3040 # 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):
3545 if self .phantom_exists_for_region (line_region ) and not prevving :
3646 continue
3747
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+
4051 full_path = self .view .file_name ()
4152
4253 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 )
4455 except Exception as e :
4556 communicate_error (e )
4657 return
@@ -67,6 +78,7 @@ def run(self, edit, sha_skip_list=[], prevving=False):
6778 user = user ,
6879 date = date ,
6980 time = time ,
81+ qs_row_num_val = quote_plus (str (row_num )),
7082 qs_sha_val = quote_plus (sha_normalised ),
7183 # Querystrings can contain the same key multiple times. We use that
7284 # functionality to accumulate a list of SHAs to skip over when
@@ -153,10 +165,16 @@ def handle_phantom_button(self, href):
153165 )
154166 elif url .path == "prev" :
155167 sha = querystring ["sha" ][0 ]
168+ row_num = querystring ["row_num" ][0 ]
156169 sha_skip_list = querystring .get ("skip" , [])
157170 if sha not in sha_skip_list :
158171 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+ )
160178 elif url .path == "close" :
161179 # Erase all phantoms
162180 self .phantom_set .update ([])
0 commit comments