fix: strip CR from multiline input on Windows#57
Merged
Conversation
On Windows, reedline inserts CRLF for newlines when building multiline
input (via InsertNewline in line_buffer.rs). R doesn't accept CR in code
and treats it as an invalid token, causing "invalid token" errors for
any multiline input like `{ }` split across lines.
Reprex mode was unaffected because strip_reprex_output() uses
.lines().join("\n") which removes CR as a side effect.
This fix strips CR from code before passing it to R, matching how we
already handle CR in error output (PR #56).
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Make strip_cr() public in arf-libr so it can be reused by arf-console. This addresses the roborev feedback about CR handling being scattered across multiple locations. The function now serves both use cases: - Output: stripping CR from R error messages - Input: stripping CR from reedline multiline input Co-Authored-By: Claude Opus 4.5 <[email protected]>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
strip_cr()functionDetails
On Windows, reedline's
InsertNewlineinserts\r\n(CRLF) instead of just\n. When users enter multiline code like:{ }The internal buffer becomes
{\r\n}. R doesn't accept CR in code and treats it as an invalid token.Reprex mode was unaffected because
strip_reprex_output()uses.lines().join("\n")which removes CR as a side effect.Refactoring
Per roborev feedback, consolidated CR stripping into a shared
strip_cr()function inarf-librthat handles both:Test plan
{ }split across lines🤖 Generated with Claude Code