mirror of
https://github.com/neovim/neovim.git
synced 2026-07-17 22:51:20 +00:00
feat(api): add nvim_win_resize()
Ref #6645 Problem: When a window is resized it takes space from the window right/below first, and only falls back to the window left/above when there is no more room. Sometimes a user wants the space to come from a specific direction. Solution: Add nvim_win_resize(win, width, height, {anchor}) which resizes a window with a choosable anchor edge, letting a window grow leftwards or upwards by taking space from the window to the left or above first. The default anchor reproduces nvim_win_set_width()/nvim_win_set_height().
This commit is contained in:
@@ -677,7 +677,7 @@ local function update_popup_window(winid, bufnr, kind)
|
||||
vim.treesitter.start(bufnr, kind)
|
||||
end
|
||||
local all = api.nvim_win_text_height(winid, {}).all
|
||||
api.nvim_win_set_height(winid, all)
|
||||
api.nvim_win_resize(winid, -1, all, {})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1625,7 +1625,7 @@ function M.open_floating_preview(contents, syntax, opts)
|
||||
local win_height = api.nvim_win_get_height(floating_winnr)
|
||||
local text_height = api.nvim_win_text_height(floating_winnr, { max_height = win_height }).all
|
||||
if text_height < win_height then
|
||||
api.nvim_win_set_height(floating_winnr, text_height)
|
||||
api.nvim_win_resize(floating_winnr, -1, text_height, {})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user