Properly handle \r\n pairs in doc-comments.

This commit is contained in:
Stephen Chung
2022-01-17 23:15:51 +08:00
parent d58df1fb34
commit f0781c9736
2 changed files with 10 additions and 1 deletions

View File

@@ -1594,7 +1594,7 @@ fn get_next_token_inner(
eat_next(stream, pos);
pos.new_line();
// `\r\n
if stream.peek_next().map(|ch| ch == '\n').unwrap_or(false) {
if let Some('\n') = stream.peek_next() {
eat_next(stream, pos);
}
}
@@ -1761,6 +1761,14 @@ fn get_next_token_inner(
};
while let Some(c) = stream.get_next() {
if c == '\r' {
pos.new_line();
// \r\n
if let Some('\n') = stream.peek_next() {
eat_next(stream, pos);
}
break;
}
if c == '\n' {
pos.new_line();
break;