fix(jj): refresh LOCAL buffers in place on NOOP refresh - #320
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The change is small, guarded, a no-op for non-jj adapters, and backed by targeted tests, with no dangling references or objective issues found.
Pull request overview
This PR changes how the jj adapter refreshes LOCAL (working-copy) buffers during a NOOP refresh. Previously, JjAdapter:force_entry_refresh_on_noop returned true for any LOCAL-touching range, forcing a full entry rebuild that tore down and re-loaded diff buffers (briefly attaching them to diffview://null) and reset the user's cycled layout. This override is removed; instead, the diff view's NOOP-keep path now explicitly routes each LOCAL side through adapter:on_local_buffer_reused, which reloads any jj-rewritten working-copy content in place via checktime. This addresses flicker on tab switching (#312) while keeping the kept-entry path intact for other adapters (a no-op for git/hg).
Changes:
- Remove
JjAdapter:force_entry_refresh_on_noop, letting jj inherit the basefalse, and update theon_local_buffer_reuseddoc comment. - In the diff view NOOP-keep branch, call
adapter:on_local_buffer_reusedfor each valid LOCAL-side buffer. - Update jj adapter tests and add a
diff_view_spectest assertingon_local_buffer_reusedis called for kept LOCAL entries.
File summaries
| File | Description |
|---|---|
| lua/diffview/vcs/adapters/jj/init.lua | Drops the force_entry_refresh_on_noop override and refreshes the on_local_buffer_reused explanatory comment. |
| lua/diffview/scene/views/diff/diff_view.lua | Adds a guarded loop in the NOOP-keep branch that invokes on_local_buffer_reused on valid LOCAL buffers. |
| lua/diffview/tests/functional/jj_adapter_spec.lua | Updates the test to assert jj now inherits the base false for all rev pairs. |
| lua/diffview/tests/functional/diff_view_spec.lua | Adds a regression test verifying on_local_buffer_reused fires for LOCAL files kept across a NOOP refresh. |
Review details
- Files reviewed: 4/4 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, thank you for the fix! It makes the responsiveness much better - the |
Motivated by #315 (comment).
Drop the
JjAdapter:force_entry_refresh_on_noop, but explicitly calladapter:on_local_buffer_reused(f.bufnr)on every LOCAL side of the kept entry, to prevent flickering on tab switching injjnoted in #312 (comment).