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

Commit e37f468

Browse files
committed
Change \r detection much simpler.
1 parent 6a316e3 commit e37f468

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/comment.rs

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

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-
}
1307+
while let Some((kind, c)) = self.base.next() {
13141308
if c == '\n' {
13151309
self.kind = match (start_class, kind) {
13161310
(FullCodeCharKind::Normal, FullCodeCharKind::InString) => {
@@ -1327,6 +1321,11 @@ impl<'a> Iterator for LineClasses<'a> {
13271321
}
13281322
}
13291323

1324+
// Workaround for CRLF newline.
1325+
if line.ends_with('\r') {
1326+
line.pop();
1327+
}
1328+
13301329
Some((self.kind, line))
13311330
}
13321331
}

0 commit comments

Comments
 (0)