Skip to content

Should the diff view grow a git-style ignore-whitespace control? #38

Closed

Description

@noyobo

The problem we hit

A file whose only change is indentation still paints a full add/del pair. There is no control to hide it.

macOS, WKWebView, app 0.16.0. Fixture: committed one\n two\nthree\n, worktree one\ntwo\nthree\n. The diff reports 1 addition and 1 deletion. This is not the unwrapped-minified-line jank, and not a missing font. The lines are real content that differs only by spaces.

git already has three switches: --ignore-space-change (-b), --ignore-all-space (-w), and --ignore-space-at-eol. libgit2 exposes the same three on DiffOptions.

Options we considered

  1. One toggle mapped to --ignore-all-space (-w). Indent and spaces inside the line both disappear. a b versus ab also disappears, which is more than "ignore the indent".
  2. One toggle mapped to --ignore-space-change (-b). A change in the amount of whitespace is hidden. Removing the space entirely (a b versus ab) still shows.
  3. --ignore-space-at-eol only. Trailing whitespace drops out. Indent changes stay.
  4. Three controls, matching the three git flags. The diff bar gets crowded.
  5. Leave it out. The user runs git in a terminal when they want -w.

While the flag is on, the hunks are not the patch git apply would stage. We turn hunk stage off in that mode rather than stage the filtered text.

What we verified works

Option 1, as a boolean on the file, commit, and range diff calls, passed through to libgit2 DiffOptions::ignore_whitespace.

On the fixture above, the same file diff with the flag set reports 0 additions and 0 deletions. With the flag clear, the indent change is still a non-zero delta. A real token change is unaffected. We did not implement -b or --ignore-space-at-eol.

Questions for the maintainer

  1. Do you want an ignore-whitespace control on the diff at all?
  2. If yes, is one flag enough, and which git switch should it be: -b, -w, or --ignore-space-at-eol?
  3. Should hunk stage stay disabled while the flag is on, since the displayed hunks are not the patch git would apply?

Activity

  1. cheat2001 commented on Sep 28, 2026

    @cheat2001
    Owner

    Yes, I want it. One toggle mapped to -w, as a checkbox in the diff header's View options menu next to word diff, wrap and whole file, persisted with them. It applies to every diff we show (working copy, commit, file history, range). Hunk and line staging go off while it's on, with a hint that the hunks aren't the patch git would apply. Three switches is more than the diff bar should carry.

    For the PR: a demo-mode path so the e2e can flip it on the indent-only fixture, no comments in source, and a line under Unreleased in CHANGELOG.md. Happy to take it since you have it working.

  2. cheat2001 commented on Sep 30, 2026

    @cheat2001
    Owner

    Out in 0.20.0, thanks for the PR. One small follow-up on main: a file whose only change is whitespace now says "Only whitespace changed in this file" instead of showing an empty diff.

  3. noyobo commented on Sep 30, 2026

    @noyobo
    ContributorAuthor

    I just thought a single line of text looked too plain, so I turned that blank into a centered panel: an icon, a title, and one short line. The whitespace-only file from your note is one of them. The same panel covers the other full-pane blanks that were only a sentence. That is #50.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions