File tree Expand file tree Collapse file tree 1 file changed +17
-14
lines changed
Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -781,20 +781,23 @@ pub fn write_ansi_range(
781781 for ( s, is_ansi) in AnsiCodeIterator :: new ( text) {
782782 if is_ansi {
783783 formatter. write_str ( s) ?;
784- } else if pos < end {
785- for c in s. chars ( ) {
786- #[ cfg( feature = "unicode-width" ) ]
787- let c_width = c. width ( ) . unwrap_or ( 0 ) ;
788- #[ cfg( not( feature = "unicode-width" ) ) ]
789- let c_width = 1 ;
790- if start <= pos && pos + c_width <= end {
791- formatter. write_char ( c) ?;
792- }
793- pos += c_width;
794- if pos > end {
795- // no need to iterate over the rest of s
796- break ;
797- }
784+ continue ;
785+ } else if pos >= end {
786+ continue ;
787+ }
788+
789+ for c in s. chars ( ) {
790+ #[ cfg( feature = "unicode-width" ) ]
791+ let c_width = c. width ( ) . unwrap_or ( 0 ) ;
792+ #[ cfg( not( feature = "unicode-width" ) ) ]
793+ let c_width = 1 ;
794+ if start <= pos && pos + c_width <= end {
795+ formatter. write_char ( c) ?;
796+ }
797+ pos += c_width;
798+ if pos > end {
799+ // no need to iterate over the rest of s
800+ break ;
798801 }
799802 }
800803 }
You can’t perform that action at this time.
0 commit comments