Skip to content

parser: only drop "\ No newline" marker lines - #599

Open
bardrop wants to merge 1 commit into
rtfpessoa:masterfrom
bardrop-oss:fix-no-newline-marker-content
Open

bardrop wants to merge 1 commit into
rtfpessoa:masterfrom
bardrop-oss:fix-no-newline-marker-content

Conversation

@bardrop

@bardrop bardrop commented Nov 12, 2026

Copy link
Copy Markdown

Fixes #598

The parser removed every "\ No newline at end of file" string from the whole input before it split the input into lines. So when the diff is for a patch file, content lines like \ No newline at end of file lost that text and showed up as , - or +.

Now the parser only skips lines that start with \ , in the same check that already skips empty lines. This is how git apply finds the marker, and it also covers translated markers from GNU diff.

Output for normal diffs does not change. I checked parse() output against master for every diff in the tests and for real git diff / diff -u output, with LF, CRLF and CR line endings, and with diffMaxChanges and diffMaxLineLength set.

Added a test for a diff of a patch file. npm test, npm run lint:check and tsc --noEmit pass.

Note: #556 (for #157) also removes the global replace, to show the marker in the output. This PR only stops content lines from being changed, so the two should be easy to combine.

The parser removed every "\ No newline at end of file" string from
the whole input before splitting it into lines. When the diff is for
a patch file, content lines like " \ No newline at end of file" lost
that text and showed up as " ", "-" or "+".

Now only lines that start with "\ " are skipped. This matches how
git apply finds the marker, and it also skips translated markers
from GNU diff.

Fixes rtfpessoa#598

This branch has not been deployed

No deployments
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.

Parser deletes the text \ No newline at end of file from diff content lines, not only marker lines

1 participant