Skip to content

Commit 6d4e7d3

Browse files
djcchris-laplante
authored andcommitted
style: tweak write_ansi_range() style
1 parent 01957a7 commit 6d4e7d3

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/style.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)