Skip to content

Add an ignore-whitespace mode for reviewing pure reindentation #794

Description

@andreifilip123

What do you want to change?

Add a way to ignore whitespace-only changes when rendering a diff — equivalent to git diff -w / --ignore-space-change (and ideally --ignore-all-space too). A CLI flag (e.g. --ignore-space-change) and/or a config option would both work; a runtime toggle keybinding (similar to how t opens the theme selector) would also be great so it can be flipped on for a specific file without restarting the session.

Why?

Hunk diffs line-by-line, not structurally (per the README's own feature comparison table, "Structural diffing" is unchecked for Hunk). That's fine in general, but it means a change that's purely a reindentation — e.g. wrapping an existing JSX block in a new {condition && ( ... )} — shows every line inside that block as a full delete+insert, even though the only difference is one extra level of leading whitespace.

I hit this reviewing a real diff: a component added one gated prop and wrapped an existing ~66-line block in a conditional. Semantically that's a tiny change, but Hunk (correctly, per git) rendered it as 84 insertions / 66 deletions, because every wrapped line shifted by one indent level. Being able to toggle "ignore whitespace" would let me confirm at a glance that the wrapped content itself didn't change, without leaving Hunk to run git diff -w separately.

I checked hunk diff --help, the README's config table, and the app bundle for anything like ignoreWhitespace / ignore-space / -w — nothing exists today.

How? (optional)

Mirror git's own options where practical:

  • --ignore-space-change (git diff's -w): ignore changes in amount of whitespace.
  • --ignore-all-space: ignore whitespace entirely when comparing lines.

These could map onto whatever diffing step currently produces hunks from git output, or (if Hunk computes its own line diff rather than shelling out) onto that diff algorithm's whitespace handling. A whitespace = "ignore-change" | "ignore-all" | "show" config key alongside the other ~/.config/hunk/config.toml options, plus a matching CLI flag and keybinding, would cover both the "always on for me" and "just checking this one file" use cases.

Version: 0.17.7 (npm hunkdiff)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions