@@ -7,7 +7,7 @@ use crate::{
77 } ,
88 keys:: { key_match, SharedKeyConfig } ,
99 popups:: { FileRevOpen , InspectCommitOpen } ,
10- queue:: { InternalEvent , Queue , StackablePopupOpen } ,
10+ queue:: { Context , InternalEvent , Queue , StackablePopupOpen } ,
1111 string_utils:: tabs_to_spaces,
1212 strings,
1313 ui:: { self , style:: SharedTheme , AsyncSyntaxJob , SyntaxText } ,
@@ -35,7 +35,8 @@ static NO_AUTHOR: &str = "<no author>";
3535static MIN_AUTHOR_WIDTH : usize = 3 ;
3636static MAX_AUTHOR_WIDTH : usize = 20 ;
3737
38- struct SyntaxFileBlame {
38+ #[ derive( Debug , Clone ) ]
39+ pub struct SyntaxFileBlame {
3940 pub file_blame : FileBlame ,
4041 pub styled_text : Option < SyntaxText > ,
4142}
@@ -54,7 +55,8 @@ impl SyntaxFileBlame {
5455 }
5556}
5657
57- enum BlameProcess {
58+ #[ derive( Clone , Debug ) ]
59+ pub enum BlameProcess {
5860 GettingBlame ( AsyncBlame ) ,
5961 SyntaxHighlighting {
6062 unstyled_file_blame : SyntaxFileBlame ,
@@ -81,6 +83,7 @@ pub struct BlameFileOpen {
8183 pub file_path : String ,
8284 pub commit_id : Option < CommitId > ,
8385 pub selection : Option < usize > ,
86+ pub blame : Option < BlameProcess > ,
8487}
8588
8689pub struct BlameFilePopup {
@@ -324,7 +327,9 @@ impl Component for BlameFilePopup {
324327 self . hide_stacked ( true ) ;
325328 self . visible = true ;
326329 self . queue . push ( InternalEvent :: OpenPopup (
327- StackablePopupOpen :: GotoLine ,
330+ StackablePopupOpen :: GotoLine ( Context :: Blame (
331+ self . blame . clone ( ) ,
332+ ) ) ,
328333 ) ) ;
329334 }
330335
@@ -375,6 +380,7 @@ impl BlameFilePopup {
375380 file_path : request. file_path ,
376381 commit_id : request. commit_id ,
377382 selection : self . get_selection ( ) ,
383+ blame : self . blame . clone ( ) ,
378384 } ) ,
379385 ) ) ;
380386 }
@@ -390,11 +396,15 @@ impl BlameFilePopup {
390396 file_path : open. file_path ,
391397 commit_id : open. commit_id ,
392398 } ) ;
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+ } ;
398408 self . table_state . get_mut ( ) . select ( Some ( 0 ) ) ;
399409 self . visible = true ;
400410 self . update ( ) ?;
@@ -457,7 +467,6 @@ impl BlameFilePopup {
457467 ) ,
458468 } ,
459469 ) ;
460- self . set_open_selection ( ) ;
461470 self . highlight_blame_lines ( ) ;
462471
463472 return Ok ( ( ) ) ;
@@ -468,6 +477,7 @@ impl BlameFilePopup {
468477 }
469478 }
470479 }
480+ self . set_open_selection ( ) ;
471481
472482 Ok ( ( ) )
473483 }
0 commit comments