@@ -31,7 +31,7 @@ use helix_view::{
3131 keyboard:: { KeyCode , KeyModifiers } ,
3232 Document , Editor , Theme , View ,
3333} ;
34- use std:: { collections :: HashMap , mem:: take, num:: NonZeroUsize , path:: PathBuf , rc:: Rc } ;
34+ use std:: { mem:: take, num:: NonZeroUsize , path:: PathBuf , rc:: Rc } ;
3535
3636use tui:: { buffer:: Buffer as Surface , text:: Span } ;
3737
@@ -214,37 +214,44 @@ impl EditorView {
214214 {
215215 decorations. add_decoration ( InlineBlame :: new (
216216 theme,
217- HashMap :: from ( [ ( cursor_line_idx, line_blame) ] ) ,
217+ text_decorations :: blame :: LineBlame :: OneLine ( ( cursor_line_idx, line_blame) ) ,
218218 ) ) ;
219219 } ;
220220 }
221221 } else if config. inline_blame . behaviour == InlineBlameBehaviour :: AllLines {
222222 let text = doc. text ( ) ;
223- let len_lines = text. len_lines ( ) ;
223+ let text_line_count = text. len_lines ( ) ;
224224 let view_height = view. inner_height ( ) ;
225225 let first_visible_line =
226226 text. char_to_line ( doc. view_offset ( view. id ) . anchor . min ( text. len_chars ( ) ) ) ;
227227 let first_line = first_visible_line. saturating_sub ( view_height) ;
228228 let last_line = first_visible_line
229229 . saturating_add ( view_height. saturating_mul ( 2 ) )
230- . min ( len_lines) ;
230+ . min ( text_line_count) ;
231+
232+ let mut blame_lines = vec ! [ None ; text_line_count] ;
231233
232234 // Compute ~3 times the current view height of inline blame, that way some scrolling
233235 // will not show half the view with inline blame and half without while still being faster
234236 // than rendering inline blame for the full file.
235- let blame_for_all_lines = ( first_line..last_line)
236- . filter_map ( |line_idx| {
237- // do not render inline blame for empty lines to reduce visual noise
238- if text. line ( line_idx) != doc. line_ending . as_str ( ) {
239- doc. line_blame ( line_idx as u32 , & config. inline_blame . format )
240- . ok ( )
241- . map ( |blame| ( line_idx, blame) )
242- } else {
243- None
244- }
245- } )
246- . collect ( ) ;
247- decorations. add_decoration ( InlineBlame :: new ( theme, blame_for_all_lines) ) ;
237+ let blame_for_all_lines = ( first_line..last_line) . filter_map ( |line_idx| {
238+ // do not render inline blame for empty lines to reduce visual noise
239+ if text. line ( line_idx) != doc. line_ending . as_str ( ) {
240+ doc. line_blame ( line_idx as u32 , & config. inline_blame . format )
241+ . ok ( )
242+ . map ( |blame| ( line_idx, blame) )
243+ } else {
244+ None
245+ }
246+ } ) ;
247+
248+ for ( line_idx, blame) in blame_for_all_lines {
249+ blame_lines[ line_idx] = Some ( blame) ;
250+ }
251+ decorations. add_decoration ( InlineBlame :: new (
252+ theme,
253+ text_decorations:: blame:: LineBlame :: ManyLines ( blame_lines) ,
254+ ) ) ;
248255 }
249256
250257 render_document (
0 commit comments