From 069f8c0470ecdfaa8fc7f45bf8ec8258e1faa5e7 Mon Sep 17 00:00:00 2001 From: Gadfly Date: Wed, 15 Jul 2026 11:26:05 +0800 Subject: [PATCH] fix: strip trailing CR in diff content to remove stray "CR" box 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. --- src/Commands/Diff.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs index 6edeff540..4a2f30664 100644 --- a/src/Commands/Diff.cs +++ b/src/Commands/Diff.cs @@ -204,6 +204,12 @@ private bool ParseChunkBodyLine(string line, ArraySegment lineBytes) { var prefix = line[0]; var content = line.Substring(1); + + // Strip the trailing '\r' carried over from CRLF/CR line endings; + // RawContent keeps the raw bytes for patch generation. + if (content.Length > 0 && content[^1] == '\r') + content = content[..^1]; + if (ParseLFSChange(prefix, content)) return true;