Skip to content

feat(ui): add compact mode to fold unchanged regions in diff view#344

Merged
esmuellert merged 4 commits into
esmuellert:mainfrom
fredrikaverpil:feat/compact-mode
Jun 6, 2026
Merged

feat(ui): add compact mode to fold unchanged regions in diff view#344
esmuellert merged 4 commits into
esmuellert:mainfrom
fredrikaverpil:feat/compact-mode

Conversation

@fredrikaverpil

@fredrikaverpil fredrikaverpil commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Why?

Reviewing files with scattered changes requires scrolling through large unchanged regions. A compact view that shows only hunks + context lines (like git diff output) makes it much easier to focus on what changed.

What?

  • New compact.lua module using foldmethod=expr to fold unchanged regions
  • Toggle with gc keymap, works in both side-by-side and inline layouts
  • Saves/restores user's original fold state (foldmethod, foldexpr, foldlevel, etc.)
  • Configurable context lines via diff.compact_context_lines (default 3)
  • Integrates with auto-refresh (folds update when buffer changes) and layout toggle (compact persists across t)
  • Added to g? help menu and README (also ticked the roadmap checkbox)

Notes

Toggle with `gc` to fold away unchanged code, showing only hunks plus
configurable context lines (default 3). Works in both side-by-side and
inline layouts. Saves and restores the user's original fold state when
toggling off. Integrates with auto-refresh and layout toggle.
@fredrikaverpil fredrikaverpil marked this pull request as ready for review March 25, 2026 12:55
@shrikantkalar023

Copy link
Copy Markdown

Was looking for just this. Hope this gets merged soon.

@DanWlker

Copy link
Copy Markdown

Hi any blockers to get this merged?

esmuellert and others added 3 commits June 6, 2026 16:36
# Conflicts:
#	lua/codediff/ui/keymap_help.lua
Tests in tests/ui/view/compact_spec.lua:
  - compute_visible_lines (8 unit tests covering empty changes, context
    expansion, top/bottom clamping, zero-width range anchor handling,
    overlap union, side selection, zero-context)
  - enable/disable round-trip (5 integration tests covering no-session,
    save/restore of all 6 fold options, toggle alternation, enable
    idempotence, no-changes case)

Vimdoc: add compact_context_lines and toggle_compact to the default
config snippet so :h codediff documents the new option and keymap.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@esmuellert esmuellert enabled auto-merge June 6, 2026 21:09
@esmuellert esmuellert merged commit fc833c0 into esmuellert:main Jun 6, 2026
13 checks passed
@fredrikaverpil fredrikaverpil deleted the feat/compact-mode branch June 7, 2026 06:42
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.

feat: fold non relevent sections for huge files in file history commit view

4 participants