Skip to content

fix(jj): refresh LOCAL buffers in place on NOOP refresh - #320

Merged
dlyongemallo merged 1 commit into
mainfrom
jj_refresh_buffers_in_place
Sep 8, 2026
Merged

fix(jj): refresh LOCAL buffers in place on NOOP refresh#320
dlyongemallo merged 1 commit into
mainfrom
jj_refresh_buffers_in_place

Conversation

@dlyongemallo

Copy link
Copy Markdown
Owner

Motivated by #315 (comment).

Drop the JjAdapter:force_entry_refresh_on_noop, but explicitly call adapter:on_local_buffer_reused(f.bufnr) on every LOCAL side of the kept entry, to prevent flickering on tab switching in jj noted in #312 (comment).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 base false, and update the on_local_buffer_reused doc comment.
  • In the diff view NOOP-keep branch, call adapter:on_local_buffer_reused for each valid LOCAL-side buffer.
  • Update jj adapter tests and add a diff_view_spec test asserting on_local_buffer_reused is 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.

@jakubbortlik

Copy link
Copy Markdown

Hi David, thank you for the fix! It makes the responsiveness much better - the diffview://null flicker is gone. The redraw of the files when switching tabs is still slower with the jj adapter than with the git adapter, but I don't thank that's something that needs any more attention.

@dlyongemallo
dlyongemallo merged commit be86a00 into main Sep 8, 2026
9 checks passed
@dlyongemallo
dlyongemallo deleted the jj_refresh_buffers_in_place branch September 8, 2026 07:56
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.

3 participants