Skip to content

Commit

Permalink
allow window stack to shrink its width again
Browse files Browse the repository at this point in the history
The functionality to equalize the width all windows in a stack only
allows to grow the width so far. This was basically the result of the
mistake to use the window width for comparison. Once the stack adapted
its size the first time, it will always just continue to grow by
definition.
The solution to this is to use the buffer width of eachs window in the
stack. This will then also shrink all windows again.
  • Loading branch information
weilbith committed Oct 15, 2021
1 parent 2caecc5 commit 977abc8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lua/code_action_menu/windows/stacking_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,11 @@ function StackingWindow:after_opened()
local last_window = self.window_stack[#self.window_stack]

if not last_window.is_anchor then
local own_width = vim.api.nvim_win_get_width(self.window_number)
local last_window_width = vim.api.nvim_win_get_width(
last_window.window_number
)
local own_width = buffer_utils.get_buffer_width(self.buffer_number)
local last_width = buffer_utils.get_buffer_width(last_window.buffer_number)

if last_window_width >= own_width then
self:set_window_width(last_window_width)
if last_width >= own_width then
self:set_window_width(last_width)
else
for _, window in ipairs(self.window_stack) do
if not window.is_anchor then
Expand Down

0 comments on commit 977abc8

Please sign in to comment.