@@ -254,53 +254,57 @@ impl EditorView {
254254 decorations : & mut DecorationManager ,
255255 theme : & Theme ,
256256 ) {
257- if inline_blame. behaviour == InlineBlameBehaviour :: CursorLine {
258- let cursor_line_idx = doc. cursor_line ( view. id ) ;
257+ match inline_blame. behaviour {
258+ InlineBlameBehaviour :: Hidden => ( ) ,
259+ InlineBlameBehaviour :: CursorLine => {
260+ let cursor_line_idx = doc. cursor_line ( view. id ) ;
259261
260- // do not render inline blame for empty lines to reduce visual noise
261- if doc. text ( ) . line ( cursor_line_idx) != doc. line_ending . as_str ( ) {
262- if let Ok ( line_blame) = doc. line_blame ( cursor_line_idx as u32 , & inline_blame. format )
263- {
264- decorations. add_decoration ( InlineBlame :: new (
265- theme,
266- text_decorations:: blame:: LineBlame :: OneLine ( ( cursor_line_idx, line_blame) ) ,
267- ) ) ;
268- } ;
269- }
270- } else if inline_blame. behaviour == InlineBlameBehaviour :: AllLines {
271- let text = doc. text ( ) ;
272- let text_line_count = text. len_lines ( ) ;
273- let view_height = view. inner_height ( ) ;
274- let first_visible_line =
275- text. char_to_line ( doc. view_offset ( view. id ) . anchor . min ( text. len_chars ( ) ) ) ;
276- let first_line = first_visible_line. saturating_sub ( view_height) ;
277- let last_line = first_visible_line
278- . saturating_add ( view_height. saturating_mul ( 2 ) )
279- . min ( text_line_count) ;
280-
281- let mut blame_lines = vec ! [ None ; text_line_count] ;
282-
283- // Compute ~3 times the current view height of inline blame, that way some scrolling
284- // will not show half the view with inline blame and half without while still being faster
285- // than rendering inline blame for the full file.
286- let blame_for_all_lines = ( first_line..last_line) . filter_map ( |line_idx| {
287262 // do not render inline blame for empty lines to reduce visual noise
288- if text. line ( line_idx) != doc. line_ending . as_str ( ) {
289- doc. line_blame ( line_idx as u32 , & inline_blame. format )
290- . ok ( )
291- . map ( |blame| ( line_idx, blame) )
292- } else {
293- None
263+ if doc. text ( ) . line ( cursor_line_idx) != doc. line_ending . as_str ( ) {
264+ if let Ok ( line_blame) = doc. line_blame ( cursor_line_idx as u32 , & inline_blame. format )
265+ {
266+ decorations. add_decoration ( InlineBlame :: new (
267+ theme,
268+ text_decorations:: blame:: LineBlame :: OneLine ( ( cursor_line_idx, line_blame) ) ,
269+ ) ) ;
270+ } ;
294271 }
295- } ) ;
272+ } ,
273+ InlineBlameBehaviour :: AllLines => {
274+ let text = doc. text ( ) ;
275+ let text_line_count = text. len_lines ( ) ;
276+ let view_height = view. inner_height ( ) ;
277+ let first_visible_line =
278+ text. char_to_line ( doc. view_offset ( view. id ) . anchor . min ( text. len_chars ( ) ) ) ;
279+ let first_line = first_visible_line. saturating_sub ( view_height) ;
280+ let last_line = first_visible_line
281+ . saturating_add ( view_height. saturating_mul ( 2 ) )
282+ . min ( text_line_count) ;
283+
284+ let mut blame_lines = vec ! [ None ; text_line_count] ;
285+
286+ // Compute ~3 times the current view height of inline blame, that way some scrolling
287+ // will not show half the view with inline blame and half without while still being faster
288+ // than rendering inline blame for the full file.
289+ let blame_for_all_lines = ( first_line..last_line) . filter_map ( |line_idx| {
290+ // do not render inline blame for empty lines to reduce visual noise
291+ if text. line ( line_idx) != doc. line_ending . as_str ( ) {
292+ doc. line_blame ( line_idx as u32 , & inline_blame. format )
293+ . ok ( )
294+ . map ( |blame| ( line_idx, blame) )
295+ } else {
296+ None
297+ }
298+ } ) ;
296299
297- for ( line_idx, blame) in blame_for_all_lines {
298- blame_lines[ line_idx] = Some ( blame) ;
299- }
300- decorations. add_decoration ( InlineBlame :: new (
301- theme,
302- text_decorations:: blame:: LineBlame :: ManyLines ( blame_lines) ,
303- ) ) ;
300+ for ( line_idx, blame) in blame_for_all_lines {
301+ blame_lines[ line_idx] = Some ( blame) ;
302+ }
303+ decorations. add_decoration ( InlineBlame :: new (
304+ theme,
305+ text_decorations:: blame:: LineBlame :: ManyLines ( blame_lines) ,
306+ ) ) ;
307+ } ,
304308 }
305309 }
306310
0 commit comments