Skip to content

fix(view): serialise _set_file so rapid navigation lands on the latest file#196

Merged
dlyongemallo merged 1 commit into
mainfrom
serialise_set_file
May 21, 2026
Merged

fix(view): serialise _set_file so rapid navigation lands on the latest file#196
dlyongemallo merged 1 commit into
mainfrom
serialise_set_file

Conversation

@dlyongemallo
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a rapid-navigation race in Diffview’s file switching by serializing StandardView:_set_file() so overlapping file-open operations are coalesced and only the latest requested file is ultimately opened.

Changes:

  • Implemented a queued/serialized _set_file workflow in StandardView using _set_file_in_flight + _set_file_pending.
  • Removed per-subclass _set_file implementations in DiffView and FileHistoryView, and introduced a _detach_files_for_next() hook for subclass-specific detach behavior.
  • Added functional tests covering the queuing/serialization contract and verifying subclass detach behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lua/diffview/scene/views/standard/standard_view.lua Adds _set_file serialization and a drain worker to coalesce concurrent file-switch requests.
lua/diffview/scene/views/diff/diff_view.lua Removes subclass _set_file so DiffView inherits the serialized StandardView behavior.
lua/diffview/scene/views/file_history/file_history_view.lua Replaces custom _set_file with _detach_files_for_next() override (swap semantics).
lua/diffview/tests/functional/standard_view_spec.lua Adds functional tests for _set_file serialization and detach-hook behavior.
lua/diffview/tests/functional/diff_view_spec.lua Notes that _set_file coalescing is tested via StandardView.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lua/diffview/tests/functional/standard_view_spec.lua Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

lua/diffview/tests/functional/standard_view_spec.lua:403

  • Similar to the serialization test above: this helper relies on calling cbs[1]() to let the _set_file worker complete and release its Future from async._handles. If anything in the pcall body errors before the callback is invoked, the suspended coroutine will linger for the rest of the suite. Consider ensuring callbacks are drained in a protected cleanup section that runs even when the test fails (e.g., xpcall + cleanup, or always pcall any collected callbacks before rethrowing).
    local ok, err = pcall(function()
      StandardView._set_file(view, target)
      -- Let the worker open the requested file so we can inspect the
      -- captured layout method calls, then resolve to drain the loop.
      cbs[1]()
    end)

Comment thread lua/diffview/tests/functional/standard_view_spec.lua
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@dlyongemallo dlyongemallo merged commit 031f1e8 into main May 21, 2026
11 checks passed
@dlyongemallo dlyongemallo deleted the serialise_set_file branch May 21, 2026 11:46
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.

2 participants