Repository navigation
fix(cli): prevent carriage returns (^M) in help menu on Windows - #19629
Conversation
…ell#19617) Signed-off-by: Abdul karim mia <[email protected]>
|
@kronberger-droid I thought we already fixed this? |
|
Yeah I thought so too... but might be another case, where escaping showed a parser bug. |
|
Well that seems more like hardcoded ones. |
|
I am fine with landing this after you make clippy happy. But it opened up an issue in reedline, that should fix why we had to print |
…ith_newline Signed-off-by: Abdul karim mia <[email protected]>
|
@kronberger-droid Clippy is happy now! Replaced write! with writeln! in help_completions.rs to address write_with_newline. Ready for review. |
There was a problem hiding this comment.
Review overview
🟡 Changes recommended
The fix works for the built-in help text: on macOS, F1 on cd shows 21 ^Ms on main and none on the branch. A multi-line @example from a CRLF file still shows one, and the new test passes with three of the changed lines reverted.
Findings: 0
Open (3)
Notes from my clanker, checked on f665096. Built the branch on Windows 10 and on macOS, and drove the F1 menu on both for cd, attr complete and a command sourced from a CRLF file: against 0.117.1 on Windows (over ssh, through ConPTY) and main (e3bf397) in a pty on macOS. Multi-line examples line up on both. On both, cargo test -p nu-cli --lib -- menus::help_completions passed 4, still passed 4 with three changed lines reverted to \r\n, and the suggested test failed with the revert and passed on the head. I didn't rerun clippy or the full tests, since CI is green on this head.
…riage returns Signed-off-by: Abdul karim mia <[email protected]>
|
@fdncred Thank you so much for the thorough review and testing! All three recommendations have been addressed in commit 2260f5f:
Ready for re-review whenever you have time, thanks! |
|
Thanks |



Description
In
crates/nu-cli/src/menus/help_completions.rs,NuHelpCompleterwas hardcoding\r\nline separators and transforming command examples with.replace('\n', "\r\n"). In raw terminal mode, reedline splits completion descriptions by\n, leaving behind unstripped carriage returns (\r) at the end of each line which render as literal^Mglyphs in the F1 help menu. Furthermore, multiline examples sourced from CRLF files preserved\r\n.This PR standardizes
NuHelpCompleteron\nline endings, normalizes multiline examples via.replace("\r\n", "\n"), and adds a comprehensive test asserting that no command's completion description or example contains carriage returns.User-facing changes (Release notes)
^Mcharacters in the F1 help menu.Additional notes
closes #19617