Skip to content

fix(read): preserve CRLF and the missing final newline with -n - #4872

Open
alexrain wants to merge 1 commit into
rtk-ai:developfrom
alexrain:fix/read-numbered-line-endings
Open

alexrain wants to merge 1 commit into
rtk-ai:developfrom
alexrain:fix/read-numbered-line-endings

Conversation

@alexrain

Copy link
Copy Markdown

Fixes #4816.

rtk read -n now splits on \n only, keeps each line's original ending, and omits the final newline when the file has none. A CRLF file and an unterminated last line now match cat -n content instead of losing the \r and adding a newline.

Tests: cargo test --lib format_with_line_numbers_preserves.

@CLAassistant

CLAassistant commented Oct 31, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pszymkowiak

Copy link
Copy Markdown
Collaborator

Hey @alexrain, thanks for this, the CRLF and final-newline handling is still needed: develop still goes through content.lines(). The branch conflicts because #4647 changed the same function since, replacing the │ separator with a tab. Could you rebase on develop, keep the tab, and update the test expectations to match ("1\ta\r\n2\tb")? I'll test it on Windows once it's updated.

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.

rtk read -n (target of the cat -n rewrite) drops carriage returns and adds a final newline

4 participants