Repository navigation
fix(parser): keep the \r of a CRLF line out of comment spans - #19504
Merged
kronberger-droid merged 1 commit intoNov 13, 2026
Merged
Conversation
Closed
2 tasks done
kronberger-droid
force-pushed
the
fix-crlf-doc-comments
branch
from
November 11, 2026 19:35
b8e43fa to
757c223
Compare
A comment ended at the `\n`, thus on CRLF files every doc comment description ended in `\r`. It went unnoticed until reedline 0.53 started escaping control characters, which shows it as `^M` in the completion menu (nushell#19499). `curr_offset` still stops at the `\n` so the main loop drops the `\r` and emits the same `Eol` as on LF. The `"\r\n\r\n"` split in `build_desc` patched the same leak on the consumer side and is gone, as are the tests that expected it: the `trim_end_matches('\r')` in the CRLF extra description test and the Windows-only `"detail\r"` in the nu-lsp completion tests, whose fixtures git checks out as CRLF there.
kronberger-droid
force-pushed
the
fix-crlf-doc-comments
branch
from
November 13, 2026 10:16
757c223 to
e8391c5
Compare
Contributor
|
are we ready to land this? |
Contributor
Author
|
@fdncred Yeah landed it. |
Closed
2 tasks done
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.
Description
In a file with CRLF line endings the lexer ended a comment at the
\n, thus the\rbefore it became part of theCommentspan.Every doc comment built from those spans carried it, so
defandaliasdescriptions and module comments ended in\r.It used to stay invisible, since the menu sent it raw and it only moved the cursor to column 0.
reedline 0.53 shows control characters instead of sending them, so the completion menu now prints it as
^M.The comment span now stops before a
\rthat directly precedes the\n.curr_offsetstill advances to the\n, so the main loop skips the\ras before and emits the sameEoltoken as on LF.Since no comment span can carry the
\ranymore, the"\r\n\r\n"split inbuild_descis dead and removed.Tests:
lex_comment_crlfandlex_comment_empty_crlfintest_lex.rscheck the comment span and that theEolstill lands on the\n.Two tests expected the old
\rand now assert the clean value:commands_from_crlf_source_have_extra_descriptionno longer trims it before comparing, and the nu-lsp completion tests drop their Windows-only"detail\r", since git checks those fixtures out as CRLF there.doc_comments_from_crlf_sourceadds alias and module descriptions from a CRLF source, which nothing covered before.The full
nu-parserandnu-lspsuites pass, the latter also with all LSP fixtures converted to CRLF, and sourcing a CRLF script now gives cleandescriptionandextra_descriptioninscope commands.Out of scope: string literals in a CRLF file still keep their
\r\n("a<CRLF>b"evaluates to"a\r\nb").Normalizing line endings once when a file is loaded would fix that too, but it shifts spans against the editor's buffer and changes string semantics, so that wants its own discussion.
User-facing changes (Release notes)
Fixed an issue where commands defined in a script with CRLF (Windows) line endings showed a stray
^Mat the end of their description, for example in the completion menu.Additional notes
fixes #19499