Repository navigation
Restore diff and merge layouts after a foreign split closes - #29
Merged
Merged
Conversation
Opening and closing a file tree (Neo-tree, nvim-tree, ...) in a DiffBandit tab handed its columns to whichever DiffBandit window was adjacent, and the views never laid their widths out again: the commit panel grew on every toggle and the source panes were squeezed. Two-way sessions and merge views now re-run their width layout on WinResized/VimResized when the editor size or a window they do not own changed (util/layout.foreign_layout_key). Resizes of their own windows, such as a dragged pane separator, keep the key and stay. Merge views also size from the columns their windows occupy instead of the full editor width. Fixes #28
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.
Fixes #28.
Problem
Toggling a file tree (Neo-tree, nvim-tree, …) while a DiffBandit view was open left the layout broken. Closing the tree gave its columns to whichever DiffBandit window was next to it, and the views only laid out their widths on open or a content change. With the commit panel open, the panel grew on every toggle (42 → 83 → 124 → 146 columns in a repro) until the diff panes were almost gone. Merge views had the same problem, and they also sized from
vim.o.columns, so an open tree was never accounted for.Fix
util/layout.foreign_layout_key(tabpage, owned)builds a key from the editor size plus every window the view doesn't own, with its size. Owned windows count only by id.WinResized/VimResizedwhen that key changes. The panel and gutters go back to their configured widths, and the content panes split what's left.Merge:owned_columns) instead of the full editor width.The folder view already re-runs its layout on every resize and measures only its own windows, so it's unchanged.
Tests
New
tests/integration/test_layout.lua:topleft 40vnew+close) three times each in a plain diff, a diff with the commit panel, and a 3-way merge, and checks that every window width returns to its starting value. All three cases fail onmain.nvim -l tests/run_all.lua: 20 jobs, 0 failed.The test uses a plain split as a stand-in for Neo-tree. It hasn't been checked against the real plugin.