Strip carriage returns when splitting lines - #1400
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
strings::linesis supposed to split text into lines and drop a trailing carriage return so CRLF input is handled, but the carriage return was never stripped. The code first checked for a trailing newline and returned early when it wasn't found. Since the function splits on newlines, no piece ever ends in a newline, so that check always returned early and the carriage return stripping below it was never reached.The effect shows up in input boundary detection. Those lines are handed to R's parser as a character vector, and a carriage return outside a string literal is an invalid token. Complete R code then gets misclassified, and in some cases a multi-line quoted string followed by another line is reported as incomplete. On Windows with CRLF files this meant pasted code landed in the Console but never ran.
The fix drops the dead newline check and strips the carriage return directly. A new test covers CRLF input so this does not regress.
Positron already normalizes line endings before making this request, so the user-facing bug is handled there, but any other caller or a direct request with CRLF text would still hit the same mis-parse.
Fixes #1399.