File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -649,15 +649,14 @@ fn fit_text(
649649 } ) ,
650650 )
651651 } else {
652- let mut str = l. chars ( ) . take ( cols + 1 ) . collect :: < String > ( ) ;
653- if str. chars ( ) . count ( ) > cols {
654- str. truncate ( cols - 1 ) ;
655- Either :: Right ( once ( Line :: default ( ) . spans ( vec ! [
656- Span :: raw( str ) ,
657- Span :: styled( "…" , Style :: default ( ) . add_modifier( Modifier :: DIM ) ) ,
658- ] ) ) )
659- } else {
660- Either :: Right ( once ( Line :: raw ( str) ) )
652+ match l. chars ( ) . nth ( cols) {
653+ Some ( _) => { // has more chars than cols
654+ Either :: Right ( once ( Line :: default ( ) . spans ( vec ! [
655+ Span :: raw( l. chars( ) . take( cols - 1 ) . collect:: <String >( ) ) ,
656+ Span :: styled( "…" , Style :: default ( ) . add_modifier( Modifier :: DIM ) ) ,
657+ ] ) ) )
658+ }
659+ None => Either :: Right ( once ( Line :: raw ( l. chars ( ) . take ( cols) . collect :: < String > ( ) ) ) ) ,
661660 }
662661 } ;
663662 match anchor {
You can’t perform that action at this time.
0 commit comments