@@ -97,9 +97,9 @@ impl Label {
9797#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
9898pub enum CursorPosition {
9999 CursorDiff ( DiffKind ) ,
100- CursorFile ( DiffKind , Option < usize > ) ,
101- CursorHunk ( DiffKind , Option < usize > , Option < usize > ) ,
102- CursorLine ( DiffKind , Option < usize > , Option < usize > , Option < usize > ) ,
100+ CursorFile ( DiffKind , usize ) ,
101+ CursorHunk ( DiffKind , usize , usize ) ,
102+ CursorLine ( DiffKind , usize , usize , usize ) ,
103103 None ,
104104}
105105
@@ -108,20 +108,20 @@ impl CursorPosition {
108108 if let Some ( ( _, index) ) = context. selected_line {
109109 return CursorPosition :: CursorLine (
110110 context. selected_diff . unwrap ( ) . kind ,
111- context. selected_file . map ( | ( _ , i ) | i ) ,
112- context. selected_hunk . map ( | ( _ , i ) | i ) ,
113- Some ( index) ,
111+ context. selected_file . unwrap ( ) . 1 ,
112+ context. selected_hunk . unwrap ( ) . 1 ,
113+ index,
114114 ) ;
115115 }
116116 if let Some ( ( _, index) ) = context. selected_hunk {
117117 return CursorPosition :: CursorHunk (
118118 context. selected_diff . unwrap ( ) . kind ,
119- context. selected_file . map ( | ( _ , i ) | i ) ,
120- Some ( index) ,
119+ context. selected_file . unwrap ( ) . 1 ,
120+ index,
121121 ) ;
122122 }
123123 if let Some ( ( _, index) ) = context. selected_file {
124- return CursorPosition :: CursorFile ( context. selected_diff . unwrap ( ) . kind , Some ( index) ) ;
124+ return CursorPosition :: CursorFile ( context. selected_diff . unwrap ( ) . kind , index) ;
125125 }
126126 if let Some ( diff) = context. selected_diff {
127127 return CursorPosition :: CursorDiff ( diff. kind ) ;
@@ -793,12 +793,10 @@ impl Status {
793793 let mut iter = buffer. iter_at_offset ( 0 ) ;
794794
795795 if let Some ( head) = & self . head {
796- debug ! ( "got the head {:?}" , iter. line( ) ) ;
797796 head. render ( & buffer, & mut iter, context) ;
798797 }
799798
800799 if let Some ( upstream) = & self . upstream {
801- debug ! ( "got the upstream {:?}" , iter. line( ) ) ;
802800 upstream. render ( & buffer, & mut iter, context) ;
803801 }
804802
@@ -812,17 +810,14 @@ impl Status {
812810
813811 if let Some ( conflicted) = & self . conflicted {
814812 conflicted. render ( & buffer, & mut iter, context) ;
815- conflicted. set_diff_tags ( & buffer, context) ;
816813 }
817814
818815 if let Some ( unstaged) = & self . unstaged {
819816 unstaged. render ( & buffer, & mut iter, context) ;
820- unstaged. set_diff_tags ( & buffer, context) ;
821817 }
822818
823819 if let Some ( staged) = & self . staged {
824820 staged. render ( & buffer, & mut iter, context) ;
825- staged. set_diff_tags ( & buffer, context) ;
826821 }
827822
828823 // first place is here
@@ -857,66 +852,6 @@ impl Status {
857852 self . head . as_ref ( ) . unwrap ( ) . oid
858853 }
859854
860- pub fn copy_to_clipboard < ' a > (
861- & ' a self ,
862- txt : & StageView ,
863- start_offset : i32 ,
864- end_offset : i32 ,
865- context : & mut StatusRenderContext < ' a > ,
866- ) {
867- //2
868- // in fact the content IS already copied to clipboard
869- // so, here it need to clean it from status_view artefacts
870- let buffer = txt. buffer ( ) ;
871- let start_iter = buffer. iter_at_offset ( start_offset) ;
872- let end_iter = buffer. iter_at_offset ( end_offset) ;
873- let line_from = start_iter. line ( ) ;
874- let line_from_offset = start_iter. line_offset ( ) ;
875- let line_to = end_iter. line ( ) ;
876- let line_to_offset = end_iter. line_offset ( ) ;
877- let mut clean_content: HashMap < i32 , ( String , i32 ) > = HashMap :: new ( ) ;
878- for diff in [ & self . conflicted , & self . unstaged , & self . staged ]
879- . into_iter ( )
880- . flatten ( )
881- {
882- diff. collect_clean_content ( line_from, line_to, & mut clean_content, context) ;
883- }
884- if !clean_content. is_empty ( ) {
885- let clipboard = txt. clipboard ( ) ;
886- glib:: spawn_future_local ( {
887- async move {
888- let mut new_content = String :: new ( ) ;
889- let mut replace_content = false ;
890- if let Ok ( Some ( content) ) = clipboard. read_text_future ( ) . await {
891- for ( i, line) in content. split ( "\n " ) . enumerate ( ) {
892- replace_content = true ;
893- let ind = i as i32 + line_from;
894- if let Some ( ( clean_line, clean_offset) ) = clean_content. get ( & ind) {
895- if ind == line_from && & line_from_offset >= clean_offset {
896- new_content. push_str (
897- & clean_line[ ( line_from_offset - clean_offset) as usize ..] ,
898- ) ;
899- } else if ind == line_to && & line_to_offset >= clean_offset {
900- new_content. push_str (
901- & clean_line[ ..( line_to_offset - clean_offset) as usize ] ,
902- ) ;
903- } else {
904- new_content. push_str ( clean_line) ;
905- }
906- } else {
907- new_content. push_str ( line) ;
908- }
909- new_content. push ( '\n' ) ;
910- }
911- }
912- if replace_content {
913- clipboard. set_text ( & new_content) ;
914- }
915- }
916- } ) ;
917- } ;
918- }
919-
920855 pub fn debug < ' a > ( & ' a mut self , txt : & StageView , _context : & mut StatusRenderContext < ' a > ) {
921856 let buffer = txt. buffer ( ) ;
922857 let pos = buffer. cursor_position ( ) ;
0 commit comments