From d8a6b93f438915cb50da7ffa95755da88636c6c9 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Mon, 24 Jan 2022 16:06:41 +0800 Subject: [PATCH] Fix off-by-one position error after comment line. --- CHANGELOG.md | 6 ++++++ src/tokenizer.rs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80fc04b2..035dd02a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/tokenizer.rs b/src/tokenizer.rs index b23c630e..ba6fb045 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -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' {