mirror of
https://github.com/neovim/neovim.git
synced 2026-04-19 22:10:45 +00:00
feat(api): add "max_height" argument to nvim_win_text_height (#32835)
Useful to e.g. limit the height to the window height, avoiding unnecessary work. Or to find out how many buffer lines beyond "start_row" take up a certain number of logical lines (returned in "end_row" and "end_vcol").
This commit is contained in:
@@ -1649,9 +1649,10 @@ function M.open_floating_preview(contents, syntax, opts)
|
||||
vim.treesitter.start(floating_bufnr)
|
||||
if not opts.height then
|
||||
-- Reduce window height if TS highlighter conceals code block backticks.
|
||||
local conceal_height = api.nvim_win_text_height(floating_winnr, {}).all
|
||||
if conceal_height < api.nvim_win_get_height(floating_winnr) then
|
||||
api.nvim_win_set_height(floating_winnr, conceal_height)
|
||||
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)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user