fix(view): serialise _set_file so rapid navigation lands on the latest file#196
Merged
Conversation
There was a problem hiding this comment.
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_fileworkflow inStandardViewusing_set_file_in_flight+_set_file_pending. - Removed per-subclass
_set_fileimplementations inDiffViewandFileHistoryView, 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.
321a5a0 to
aa3d49f
Compare
There was a problem hiding this comment.
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_fileworker complete and release its Future fromasync._handles. If anything in thepcallbody 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)
aa3d49f to
3ca6ac7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.