fix(panel): exclude floats from close-guard window count#192
Merged
Conversation
`Panel:close`'s total-window count disagreed with `pivot_producer`'s normal-only count, so neither created a temp split when floats (LSP, completion, treesitter-context) shared the tab. Closing the panel on a layout swap then collapsed the tabpage.
There was a problem hiding this comment.
Pull request overview
This PR fixes a tabpage-collapse edge case when closing a Diffview panel in a tab that also contains floating windows (e.g., LSP/completion UI). The close-guard logic now aligns with the view layout swap logic by counting only normal windows, ensuring a temporary split is still created when the panel is effectively the last anchoring window.
Changes:
- Update
Panel:close()to count only non-floating windows when deciding whether to create a temporary split. - Add functional tests covering (1) a normal panel with only floating siblings and (2) a floating panel closing alongside a lone editor window.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lua/diffview/ui/panel.lua | Adjusts the close-guard window counting to exclude floats and avoids splitting when the panel itself is floating. |
| lua/diffview/tests/functional/panel_spec.lua | Adds regression tests to validate correct behavior with floating sibling windows and float panels. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Panel:close's total-window count disagreed withpivot_producer's normal-only count, so neither created a temp split when floats (LSP, completion, treesitter-context) shared the tab. Closing the panel on a layout swap then collapsed the tabpage.