From 2a3711e8b82bf1ed8e32b96a91118fd9423f534f Mon Sep 17 00:00:00 2001 From: eileencodes Date: Thu, 5 Dec 2024 13:56:03 -0500 Subject: [PATCH] Increment cursor to breakpoint + 2 When there is a `\r\n` in the following example: `p eval "%\n1\r\n \n"` Prism was returning `"1\n "` whereas parse.y returns `"1"`. In this case the cursor needs to be set to the breakpoint (which is `\r`) plus 2 to ignore the new line and the space. I'm having trouble figuring out how to test this but locally here is the before and after output: Parse.y ``` $ ./miniruby --parser=parse.y test.rb "1" ``` Prism Before: ``` $ ./miniruby --parser=prism test.rb "1\n " ``` Prism after: ``` $ ./miniruby --parser=prism test.rb "1" ``` --- src/prism.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prism.c b/src/prism.c index a968e2dbbc..f97b83b4dd 100644 --- a/src/prism.c +++ b/src/prism.c @@ -12401,7 +12401,7 @@ parser_lex(pm_parser_t *parser) { breakpoint++; parser->current.end = breakpoint; pm_token_buffer_escape(parser, &token_buffer); - token_buffer.cursor = breakpoint; + token_buffer.cursor = breakpoint + 2; /* fallthrough */ case '\n':