fix(view): preserve cycled layout across force_entry_refresh_on_noop - #315
fix(view): preserve cycled layout across force_entry_refresh_on_noop#315dlyongemallo wants to merge 1 commit into
force_entry_refresh_on_noop#315Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The change is a minimal, correctly-guarded fix that mirrors the established convert_layout pattern (e.g. file_history_view.lua:405-408), covers all file collections, and is backed by a targeted regression test with valid API usage.
Pull request overview
This PR fixes issue #312, where the diff layout chosen via cycle_layout/set_layout (e.g. g<C-x>) was silently reset to the config default whenever a refresh replaced NOOP entries. This happens on adapters where force_entry_refresh_on_noop returns true — notably the jj adapter on any LOCAL-touching range, which fires on tab_enter, FocusGained, polling, or an explicit R. Because get_updated_files always rebuilds entries with the config default layout, the fix carries the old entry's layout class onto the freshly built entry before the swap, using the existing FileEntry:convert_layout mechanism.
Changes:
- In the NOOP replace-entry branch of
update_files_impl, convert the new entry to the old entry's layout class when they differ, preserving the user's cycled/set layout across refreshes. - Add a regression test simulating the
force_entry_refresh_on_noopreplace path and asserting the recreated entry keeps the user's chosen layout class.
File summaries
| File | Description |
|---|---|
lua/diffview/scene/views/diff/diff_view.lua |
Preserves the old entry's layout class on the replacement entry in the NOOP force-refresh branch. |
lua/diffview/tests/functional/diff_view_spec.lua |
Adds a regression test verifying the layout class survives the entry swap. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Hi David, thanks for addressing this. When I was trying to figure out what's wrong, Claude Code suggested that maybe the JjAdapter:force_entry_refresh_on_noop is obsolete and should be removed. Supposedly, "the staleness it guards against is now handled by One thing I can confirm though is that removing the |
Fixes #312.