@@ -7,7 +7,7 @@ use crate::{
7
7
} ,
8
8
keys:: { key_match, SharedKeyConfig } ,
9
9
popups:: { FileRevOpen , InspectCommitOpen } ,
10
- queue:: { InternalEvent , Queue , StackablePopupOpen } ,
10
+ queue:: { Context , InternalEvent , Queue , StackablePopupOpen } ,
11
11
string_utils:: tabs_to_spaces,
12
12
strings,
13
13
ui:: { self , style:: SharedTheme , AsyncSyntaxJob , SyntaxText } ,
@@ -35,7 +35,8 @@ static NO_AUTHOR: &str = "<no author>";
35
35
static MIN_AUTHOR_WIDTH : usize = 3 ;
36
36
static MAX_AUTHOR_WIDTH : usize = 20 ;
37
37
38
- struct SyntaxFileBlame {
38
+ #[ derive( Debug , Clone ) ]
39
+ pub struct SyntaxFileBlame {
39
40
pub file_blame : FileBlame ,
40
41
pub styled_text : Option < SyntaxText > ,
41
42
}
@@ -54,7 +55,8 @@ impl SyntaxFileBlame {
54
55
}
55
56
}
56
57
57
- enum BlameProcess {
58
+ #[ derive( Clone , Debug ) ]
59
+ pub enum BlameProcess {
58
60
GettingBlame ( AsyncBlame ) ,
59
61
SyntaxHighlighting {
60
62
unstyled_file_blame : SyntaxFileBlame ,
@@ -81,6 +83,7 @@ pub struct BlameFileOpen {
81
83
pub file_path : String ,
82
84
pub commit_id : Option < CommitId > ,
83
85
pub selection : Option < usize > ,
86
+ pub blame : Option < BlameProcess > ,
84
87
}
85
88
86
89
pub struct BlameFilePopup {
@@ -324,7 +327,9 @@ impl Component for BlameFilePopup {
324
327
self . hide_stacked ( true ) ;
325
328
self . visible = true ;
326
329
self . queue . push ( InternalEvent :: OpenPopup (
327
- StackablePopupOpen :: GotoLine ,
330
+ StackablePopupOpen :: GotoLine ( Context :: Blame (
331
+ self . blame . clone ( ) ,
332
+ ) ) ,
328
333
) ) ;
329
334
}
330
335
@@ -375,6 +380,7 @@ impl BlameFilePopup {
375
380
file_path : request. file_path ,
376
381
commit_id : request. commit_id ,
377
382
selection : self . get_selection ( ) ,
383
+ blame : self . blame . clone ( ) ,
378
384
} ) ,
379
385
) ) ;
380
386
}
@@ -390,11 +396,15 @@ impl BlameFilePopup {
390
396
file_path : open. file_path ,
391
397
commit_id : open. commit_id ,
392
398
} ) ;
393
- self . blame =
394
- Some ( BlameProcess :: GettingBlame ( AsyncBlame :: new (
395
- self . repo . borrow ( ) . clone ( ) ,
396
- & self . git_sender ,
397
- ) ) ) ;
399
+ self . blame = match open. blame {
400
+ None => {
401
+ Some ( BlameProcess :: GettingBlame ( AsyncBlame :: new (
402
+ self . repo . borrow ( ) . clone ( ) ,
403
+ & self . git_sender ,
404
+ ) ) )
405
+ }
406
+ blame => blame,
407
+ } ;
398
408
self . table_state . get_mut ( ) . select ( Some ( 0 ) ) ;
399
409
self . visible = true ;
400
410
self . update ( ) ?;
@@ -457,7 +467,6 @@ impl BlameFilePopup {
457
467
) ,
458
468
} ,
459
469
) ;
460
- self . set_open_selection ( ) ;
461
470
self . highlight_blame_lines ( ) ;
462
471
463
472
return Ok ( ( ) ) ;
@@ -468,6 +477,7 @@ impl BlameFilePopup {
468
477
}
469
478
}
470
479
}
480
+ self . set_open_selection ( ) ;
471
481
472
482
Ok ( ( ) )
473
483
}
0 commit comments