Skip to content

fix(panel): exclude floats from close-guard window count#192

Merged
dlyongemallo merged 1 commit into
mainfrom
fix_layout_swap_tab_close
May 20, 2026
Merged

fix(panel): exclude floats from close-guard window count#192
dlyongemallo merged 1 commit into
mainfrom
fix_layout_swap_tab_close

Conversation

@dlyongemallo
Copy link
Copy Markdown
Owner

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.

`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.
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 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.

@dlyongemallo dlyongemallo merged commit 35f7975 into main May 20, 2026
11 checks passed
@dlyongemallo dlyongemallo deleted the fix_layout_swap_tab_close branch May 20, 2026 06:15
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