File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -519,17 +519,16 @@ enum InsertLocation {
519
519
Before ( usize ) ,
520
520
}
521
521
522
- // Calculate real length based on terminal width
523
- // This take in account linewrap from terminal
524
- fn visual_line_count < StrRef : AsRef < str > > ( lines : & [ StrRef ] , width : f64 ) -> usize {
525
- lines. iter ( ) . fold ( 0 , |sum, val| {
526
- sum + if val. as_ref ( ) . is_empty ( ) {
527
- 1
528
- } else {
529
- let effective_line_length = console:: measure_text_width ( val. as_ref ( ) ) as f64 ;
530
- usize:: max ( ( effective_line_length / width) . ceil ( ) as usize , 1 )
531
- }
532
- } )
522
+ /// Calculate the number of visual lines in the given lines, after
523
+ /// accounting for line wrapping and non-printable characters.
524
+ fn visual_line_count ( lines : & [ impl AsRef < str > ] , width : f64 ) -> usize {
525
+ let mut real_lines = 0 ;
526
+ for line in lines {
527
+ let effective_line_length = console:: measure_text_width ( line. as_ref ( ) ) as f64 ;
528
+ real_lines += usize:: max ( ( effective_line_length / width) . ceil ( ) as usize , 1 ) ;
529
+ }
530
+
531
+ real_lines
533
532
}
534
533
535
534
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments