Skip to content

feat(review): hide whitespace changes, tab width and changed-text settings - #197

Merged
backnotprop merged 6 commits into
mainfrom
feat/more-diff-settings
Nov 24, 2026
Merged

backnotprop merged 6 commits into
mainfrom
feat/more-diff-settings

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Adds three diff settings to the code review, plus a key and a header chip for the whitespace one.

Settings (menu rows, live; remembered in the review settings file; settable in [review]):

Row Values (menu) [review] key and values
Whitespace show · hide (like git -w) · hide amount changes (git -b) whitespace = "show" | "ignore-all" | "ignore-change"
Tab width 2 · 4 · 8 columns tab_width = 1..=16 (default 4; the menu steps from any value to its neighbours among 2/4/8)
Changed text words · words, joined · characters · off inline_changes = "word" | "word-alt" | "char" | "none"
  • W (toggle-whitespace) hides or shows whitespace-only changes, over the diff, the file list or the notes. It is in the late group, so a user binding that already uses W keeps it. It is listed in ? help. While whitespace is hidden, a lit amber no ws chip sits beside Wrap; clicking it shows whitespace again. The chip's colours are in the chips contrast table.
  • Header and file-list +/− counts stay the patch's counts.
  • Configs written for 0.11.2 load unchanged (the compat test table is extended). Bad [review] values fail like the existing keys. Bad values in the remembered file are skipped and named once.

Behaviour while whitespace is hidden

  • Notes stay on their lines. A comment written on a pair drawn as unchanged saves the right file, side and line, and is still there after toggling back. A note inside a hunk reduced to its heading has no gutter mark until whitespace shows again; the rail says why.
  • A selection keeps its lines through a toggle. If its hunk becomes a heading alone, the selection is cleared and the footer says so. Drag and v still stay inside one hunk.
  • With the comment box open, W and , go into the draft.
  • Go to definition opens a line in a hidden hunk in the whole file. The whole-file view uses the same tab width and changed-text settings; it has no changes to hide.
  • Viewed marks, the file and kind filters, n/N, ]/[, o/O and r keep the settings. Reset puts all three back.
  • A burst of W presses is applied once, at the next frame: 50 presses draw the same frame as none.

Also in this PR

  • A remembered-settings file that cannot be read (for example, not UTF-8) is now replaced by the next write or by Reset.
  • When the config fails to load, the review and document screens show config not loaded: <reason>; using defaults (<path>) once in the footer, and keep using the defaults.
  • Fixes a pre-existing hang: in a one-file review, going to the file's heading (for example a file filter + Enter from below it) looped for ever, because the viewer reports Up at the top as a redraw.
  • Removes stale comments in Cargo.toml, config.rs and review/mod.rs.

Dependency: uses diffs-rs feat/more-options (plannotator/diffs-rs#19) through [patch.crates-io] (diffs-rs, diffs-syntect, diffs-two-face). The crate requirement is 0.2.3, the version that branch carries (head b7ef59d). Swap both for the published release before merging.

Tests: review/tests/whitespace_flow.rs (drives the real Screen), plus additions to config/review.rs, settings/state.rs, keys/tests.rs, header.rs, diff/whitespace.rs, settings_flow.rs, file_list.rs, config.rs and app/tests.rs.

W (toggle-whitespace) hides changes that only touch whitespace, like
git diff -w, and shows them again; a lit 'no ws' chip in the header says
when they are hidden. The settings menu gains Whitespace, Tab width and
Changed text rows, applied live, remembered with the other choices and
settable in [review] (whitespace, tab_width, inline_changes).

A selection whose hunk becomes a heading alone is cleared and said so;
go to definition opens such a line in the whole file. Bursts of W are
taken as one change at the next frame.

Also: a remembered-settings file that cannot be read is replaced by the
next write or Reset; a config that fails to load is said once in the
footer of the review and document screens; going to the only file's
heading no longer loops for ever.

Uses diffs-rs feat/more-options (plannotator/diffs-rs#19) through
[patch.crates-io] until it is published.
…ab is not whitespace

The patched diffs crates move to the branch head, which carries 0.2.3.
The app's rule for a hunk the viewer hides takes only space, tab, CR and
LF as whitespace, as the viewer and git diff -w/-b do, so a change to a
form feed stays shown and selectable.
… diffs-rs e320ae7

The patched diffs crates move to e320ae7, where a reveal of a line already
on screen never scrolls. A Screen test drags up in a scrolled diff with
whitespace hidden, tab width 2 and 8, changed text off, split and unified:
the view stays, the lines are those dragged over, pairs drawn as unchanged
included, and the comment saves their file, side and lines.

The wrapped-line comment-box test relied on the reveal that scrolled; it
now brings line 30 up with the wheel so the wrapped lines fit under it.
…e file list too

The patched diffs crates move to b7ef59d, which says itself whether a hunk
is drawn as its heading alone (Engine::hunk_is_whitespace_only). The app's
copy of that rule is gone: it read the patch as UTF-8, so a Latin-1 line
changed from caf\xe9 to caf\xe8 compared equal, and W cleared a selection
on a line still drawn. The app now only finds a line's hunk from the
viewer's hunk headings and asks.

W hides and shows whitespace over the file list and the notes too, unless
the pane gives the key to one of its own; the footer said so already.
@backnotprop
backnotprop added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit b5a6b8c Nov 24, 2026
3 checks passed
@backnotprop
backnotprop deleted the feat/more-diff-settings branch November 24, 2026 05:38
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.

1 participant