Skip to content

Show the "No newline at end of file" marker as a plain diff line - #3042

Open
b84330808 wants to merge 1 commit into
gitui-org:masterfrom
b84330808:fix-no-newline-marker-color
Open

b84330808 wants to merge 1 commit into
gitui-org:masterfrom
b84330808:fix-no-newline-marker-color

Conversation

@b84330808

Copy link
Copy Markdown

This Pull Request fixes/closes #2223.

It changes the following:

  • libgit2 reports the "\ No newline at end of file" marker as AddEOFNL when the newline is added and DeleteEOFNL when it is removed, but the marker always follows the line of the other side. gitui mapped them to Add/Delete, so the marker showed up green under the removed line (or red under the added line). It is now mapped to DiffLineType::None and drawn as a plain line, like git diff does.
  • Side effect: selecting only the marker line and staging lines no longer stages the neighbouring changed line (the marker shares its line number); it now behaves like any context line.
  • Added two tests in asyncgit/src/sync/diff.rs covering both directions.

I used Claude Code to write this change.

I followed the checklist:

  • I added unittests
  • I ran make check without errors
  • I tested the overall application
  • I added an appropriate item to the changelog

libgit2 reports the "\ No newline at end of file" marker as AddEOFNL
when the newline is being added and as DeleteEOFNL when it is being
removed. The marker itself follows the line of the other side, though:
AddEOFNL comes right after the deleted line and DeleteEOFNL right after
the added one. Mapping them to Add/Delete therefore coloured the marker
green below a removed line and red below an added line.

The marker is not a change of its own, so map it to DiffLineType::None
and render it like git does, as a plain line.

Fixes gitui-org#2223

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Wrong diff highlighting for "no newline at end of file"

1 participant