Skip to content

fix: strip CR from multiline input on Windows#57

Merged
eitsupi merged 3 commits intomainfrom
fix/strip-cr-input-windows
Feb 5, 2026
Merged

fix: strip CR from multiline input on Windows#57
eitsupi merged 3 commits intomainfrom
fix/strip-cr-input-windows

Conversation

@eitsupi
Copy link
Copy Markdown
Owner

@eitsupi eitsupi commented Feb 5, 2026

Summary

  • Fix "invalid token" error on Windows when entering multiline R code
  • Root cause: reedline inserts CRLF for newlines, R rejects CR as invalid token
  • Solution: Strip CR before passing code to R using shared strip_cr() function

Details

On Windows, reedline's InsertNewline inserts \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 in arf-libr that handles both:

Test plan

  • Test on Windows: enter multiline input like { } split across lines
  • Verify both normal mode and reprex mode work correctly

🤖 Generated with Claude Code

eitsupi and others added 3 commits February 5, 2026 16:20
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]>
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]>
@eitsupi eitsupi merged commit f5a19db into main Feb 5, 2026
10 checks passed
@eitsupi eitsupi deleted the fix/strip-cr-input-windows branch February 5, 2026 16:38
@eitsupi eitsupi mentioned this pull request Feb 5, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant