Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

fix(stacking_window): stabilize window widths on navigation #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Gelio
Copy link
Contributor

@Gelio Gelio commented Nov 28, 2023

Context

The order of stacked windows is: menu, details, diff. The stacking window width was set sequentially for each window and relied only on the buffer content of the last window and the current window. This meant that when the diff window content was wider than the details window content, the diff window resized all windows in its stack (menu, details) to match the width of the diff window.

Problem

This logic ignores the fact that the menu window could be wider than the details window. In such a situation, when the details window was being opened, it adjusted its width to match the width of the wider menu window. However, since the diff window only looked at buffer contents of the details window, and not at the actual window width of the details window, it assumed that the diff window is the widest one, and set the width of the menu window and the details window to match the diff window. This makes the menu window narrower than its content.

Kapture.2023-11-28.at.11.47.41.mp4

Solution

Change the StackingWindow:after_opened() window resize logic to look at the actual window width, rather than the buffer content width. When after_opened() runs for the diff window, it correctly can identify that the details window was resized due to the menu window being wider, and correctly makes all windows' width be max(diff window, previous windows).

Kapture.2023-11-28.at.11.50.35.mp4

Fixes #52

Context: The order of stacked windows is: menu, details, diff. The
stacking window width was set sequentially for each window and relied
only on the buffer content of the last window and the current window.
This meant that when the diff window content was wider than the details
window content, the diff window resized all windows in its stack (menu,
details) to match the width of the diff window.

Problem: This logic ignores the fact that the menu window could be wider
than the details window. In such a situation, when the details window
was being opened, it adjusted its width to match the width of the wider
menu window. However, since the diff window only looked at buffer
contents of the details window, and not at the actual window width of
the details window, it assumed that the diff window is the widest one,
and set the width of the menu window and the details window to match the
diff window. This makes the menu window narrower than its content.

Solution: Change the `StackingWindow:after_opened()` window resize logic
to look at the *actual* window width, rather than the buffer content
width. When `after_opened()` runs for the diff window, it correctly can
identify that the details window was resized due to the menu window
being wider, and correctly makes all windows' width be `max(diff window,
previous windows)`.

Fixes weilbith#52
Gelio added a commit to Gelio/ubuntu-dotfiles that referenced this pull request Nov 29, 2023
Until my PR that fixes window widths [0] is merged, let's use my fork to
benefit from stable window widths.

[0]: weilbith/nvim-code-action-menu#69
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Windows width changes when navigating code action menu
1 participant