From 693ff2022493649b41479244e2d22359756c5875 Mon Sep 17 00:00:00 2001 From: Myrddin Dundragon Date: Mon, 5 May 2025 18:11:47 -0400 Subject: [PATCH] Fixing how the Lexer handles text. Scanning a file has all the lines terminating with a '\n' newline character, but when giving the text directly to the lexer via the scan_text function it should not append a newline at the end if there was no newline in the original input. --- src/lexer.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lexer.rs b/src/lexer.rs index 1a2451e..85a1360 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -170,6 +170,13 @@ impl Lexer cursor.column = 0; } + // Remove the last newline character if the text did not end with a + // newline. + if !text.ends_with('\n') + { + stream.pop(); + } + Ok(transform(&stream)) }