Skip to content

fix: strip trailing CR in diff content to remove stray "CR" box#2536

Open
gadfly3173 wants to merge 1 commit into
sourcegit-scm:developfrom
gadfly3173:fix/diff-trailing-cr
Open

fix: strip trailing CR in diff content to remove stray "CR" box#2536
gadfly3173 wants to merge 1 commit into
sourcegit-scm:developfrom
gadfly3173:fix/diff-trailing-cr

Conversation

@gadfly3173

@gadfly3173 gadfly3173 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Git splits diff lines on \n, so the \r from CRLF/CR files stays glued to the line content in TextDiffLine.Content. After the editor trims the trailing newline, the last line is left with an isolated \r, which AvaloniaEdit renders as a boxed "CR" control character.

Strip it at parse time. RawContent keeps the raw bytes unchanged, so patch generation and the \r\n / \n line-ending markers are unaffected.

Introduced by commit 6a47cec

Original:

image

Git splits diff lines on '\n', so the '\r' from CRLF/CR files stays
glued to the line content in TextDiffLine.Content. After the editor
trims the trailing newline, the last line is left with an isolated
'\r', which AvaloniaEdit renders as a boxed "CR" control character.

Strip it at parse time. RawContent keeps the raw bytes unchanged, so
patch generation and the \r\n/\n line-ending markers are unaffected.
@love-linger

Copy link
Copy Markdown
Collaborator

What's the original git diff command output?

@gadfly3173

Copy link
Copy Markdown
Contributor Author
image
git -C "$REPO" --no-pager show $C | grep '^[-+]' | cat -A

@love-linger

Copy link
Copy Markdown
Collaborator

I mean the original git diff output to show the text diff

@gadfly3173

Copy link
Copy Markdown
Contributor Author

Do you mean this?

image

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.

2 participants