Skip to content

Commit 90a3959

Browse files
committed
Popup: Don't reposition if only size has changed
1 parent 61574ce commit 90a3959

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

lua/nui/popup/init.lua

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,19 +385,36 @@ end
385385
function Popup:update_layout(config)
386386
config = config or {}
387387

388+
local old_row = self.win_config.row
389+
local old_col = self.win_config.col
390+
388391
u.update_layout_config(self._, config)
389392

390393
self.border:_relayout()
391394

392395
self._.layout_ready = true
393396

394397
if self.winid then
395-
-- upstream issue: https://github.com/neovim/neovim/issues/20370
396-
local win_config_style = self.win_config.style
397-
---@diagnostic disable-next-line: assign-type-mismatch
398-
self.win_config.style = ""
399-
vim.api.nvim_win_set_config(self.winid, self.win_config)
400-
self.win_config.style = win_config_style
398+
if
399+
config.size ~= nil
400+
and vim.tbl_count(config) == 1
401+
and old_row == self.win_config.row
402+
and old_col == self.win_config.col
403+
then
404+
-- Only size got updated, so let's not reposition the popup
405+
vim.api.nvim_win_set_config(self.winid, {
406+
style = "", -- https://github.com/neovim/neovim/issues/20370
407+
width = self.win_config.width,
408+
height = self.win_config.height,
409+
})
410+
else
411+
-- upstream issue: https://github.com/neovim/neovim/issues/20370
412+
local win_config_style = self.win_config.style
413+
---@diagnostic disable-next-line: assign-type-mismatch
414+
self.win_config.style = ""
415+
vim.api.nvim_win_set_config(self.winid, self.win_config)
416+
self.win_config.style = win_config_style
417+
end
401418
end
402419
end
403420

0 commit comments

Comments
 (0)