@@ -180,25 +180,14 @@ pub fn print_unicode(graph: &GitGraph, settings: &Settings) -> Result<UnicodeGra
180180 } else {
181181 let split_index = super :: get_deviate_index ( graph, idx, * par_idx) ;
182182 let split_idx_map = index_map[ split_index] ;
183- let inserts = & inserts[ & split_index] ;
184- for ( insert_idx, sub_entry) in inserts. iter ( ) . enumerate ( ) {
185- for occ in sub_entry {
186- match occ {
187- Occ :: Commit ( _, _) => { }
188- Occ :: Range ( i1, i2, _, _) => {
189- if * i1 == idx && i2 == par_idx {
190- let inx_split = split_idx_map + insert_idx;
191-
192- let is_secondary_merge = info. is_merge && p > 0 ;
193-
194- let row123 = ( idx_map, inx_split, par_idx_map) ;
195- let col12 = ( column, par_column) ;
196- zig_zag_line ( & mut grid, row123, col12, is_secondary_merge, color, pers) ;
197- }
198- }
199- }
200- }
201- }
183+ let insert_idx = find_insert_idx ( & inserts[ & split_index] , idx, * par_idx) . unwrap ( ) ;
184+ let inx_split = split_idx_map + insert_idx;
185+
186+ let is_secondary_merge = info. is_merge && p > 0 ;
187+
188+ let row123 = ( idx_map, inx_split, par_idx_map) ;
189+ let col12 = ( column, par_column) ;
190+ zig_zag_line ( & mut grid, row123, col12, is_secondary_merge, color, pers) ;
202191 }
203192 }
204193 }
@@ -246,6 +235,20 @@ fn create_wrapping_options<'a>(
246235 Ok ( wrapping)
247236}
248237
238+ /// Find the index of the insert that connects the two commits
239+ fn find_insert_idx ( inserts : & [ Vec < Occ > ] , child_idx : usize , parent_idx : usize ) -> Option < usize > {
240+ for ( insert_idx, sub_entry) in inserts. iter ( ) . enumerate ( ) {
241+ for occ in sub_entry {
242+ if let Occ :: Range ( i1, i2, _, _) = occ {
243+ if * i1 == child_idx && * i2 == parent_idx {
244+ return Some ( insert_idx) ;
245+ }
246+ }
247+ }
248+ }
249+ None
250+ }
251+
249252/// Draw a line that connects two commits on different columns
250253fn zig_zag_line (
251254 grid : & mut Grid ,
0 commit comments