Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f3f511a

Browse files
committed
Fix rust-lang#2973 in Windows CRLF env.
1 parent a1ee7e9 commit f3f511a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/comment.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,13 @@ impl<'a> Iterator for LineClasses<'a> {
13041304
None => FullCodeCharKind::Normal,
13051305
};
13061306

1307-
while let Some((kind, c)) = self.base.next() {
1307+
while let Some((kind, mut c)) = self.base.next() {
1308+
// If \r\n newline appears, consume one more character.
1309+
// Then do the same process with the single \n case.
1310+
if c == '\r' && self.base.peek().map_or(false, |(_, c2)| *c2 == '\n') {
1311+
self.base.next();
1312+
c = '\n';
1313+
}
13081314
if c == '\n' {
13091315
self.kind = match (start_class, kind) {
13101316
(FullCodeCharKind::Normal, FullCodeCharKind::InString) => {

0 commit comments

Comments
 (0)