mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(lsp): minimum height for floating popup #31990
Problem: The floating window for hover and signature help always cuts off a few lines, because the `_make_floating_popup_size` function counts empty lines as having zero height. Solution: Ensure the height is at least 1.
This commit is contained in:
parent
34e2185022
commit
a4f575abd8
@ -1432,7 +1432,7 @@ function M._make_floating_popup_size(contents, opts)
|
|||||||
if vim.tbl_isempty(line_widths) then
|
if vim.tbl_isempty(line_widths) then
|
||||||
for _, line in ipairs(contents) do
|
for _, line in ipairs(contents) do
|
||||||
local line_width = vim.fn.strdisplaywidth(line:gsub('%z', '\n'))
|
local line_width = vim.fn.strdisplaywidth(line:gsub('%z', '\n'))
|
||||||
height = height + math.ceil(line_width / wrap_at)
|
height = height + math.max(1, math.ceil(line_width / wrap_at))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
for i = 1, #contents do
|
for i = 1, #contents do
|
||||||
|
@ -3501,6 +3501,19 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
it('handles empty line', function()
|
||||||
|
exec_lua(function()
|
||||||
|
_G.contents = {
|
||||||
|
'',
|
||||||
|
}
|
||||||
|
end)
|
||||||
|
eq(
|
||||||
|
{ 20, 1 },
|
||||||
|
exec_lua(function()
|
||||||
|
return { vim.lsp.util._make_floating_popup_size(_G.contents, { width = 20 }) }
|
||||||
|
end)
|
||||||
|
)
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('lsp.util.trim.trim_empty_lines', function()
|
describe('lsp.util.trim.trim_empty_lines', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user