nvim-code-action-menu icon indicating copy to clipboard operation
nvim-code-action-menu copied to clipboard

fix(stacking_window): stabilize window widths on navigation

Open Gelio opened this issue 1 year ago • 0 comments

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.

https://github.com/weilbith/nvim-code-action-menu/assets/889383/70514cd7-bb62-41a3-8c26-da45cf9ff8da

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

https://github.com/weilbith/nvim-code-action-menu/assets/889383/4f4a2c7e-494a-4bae-b5c7-b432cbb9ddee

Fixes #52

Gelio avatar Nov 28 '23 10:11 Gelio