Fix off-by-one position error after comment line.

This commit is contained in:
Stephen Chung 2022-01-24 16:06:41 +08:00
parent 2b2685e387
commit d8a6b93f43
2 changed files with 8 additions and 2 deletions

View File

@ -8,6 +8,12 @@ Bug fixes
---------
* Variables introduced inside `try` blocks are now properly cleaned up upon an exception.
* Off-by-one error in character positions after a comment line is now fixed.
Enhancements
------------
* `rhai-repl` tool has a few more commands, such as `strict` to turn on/off _Strict Variables Mode_ and `optimize` to turn on/off script optimization.
Version 1.4.1

View File

@ -1592,11 +1592,11 @@ fn get_next_token_inner(
// `\r - start from next line
Some('\r') => {
eat_next(stream, pos);
pos.new_line();
// `\r\n
if let Some('\n') = stream.peek_next() {
eat_next(stream, pos);
}
pos.new_line();
}
// `\n - start from next line
Some('\n') => {
@ -1762,11 +1762,11 @@ 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);
}
pos.new_line();
break;
}
if c == '\n' {