Skip to content
This repository was 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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lua/code_action_menu/windows/stacking_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ function StackingWindow:after_opened()
local last_window = self.window_stack[#self.window_stack]

if not last_window.is_anchor then
local own_width = buffer_utils.get_buffer_width(self.buffer_number)
local last_width = buffer_utils.get_buffer_width(last_window.buffer_number)
-- NOTE: window widths are set inside each `:open()` call.
-- They could have been updated in previous `:after_opened()` for previous stacking windows.
-- We cannot rely on `buffer_utils.get_buffer_width`, because the width could have
-- been changed and be out of sync with the width suggested by the buffer contents.
local own_width = vim.api.nvim_win_get_width(self.window_number)
local last_width = vim.api.nvim_win_get_width(last_window.window_number)

if last_width >= own_width then
self:set_window_width(last_width)
Expand Down