fix(float): ensure floating window width can fit title

This commit is contained in:
Maria José Solano
2025-02-22 13:19:00 -08:00
committed by Lewis Russell
parent f932c7852e
commit d2cca606a1
2 changed files with 19 additions and 0 deletions

View File

@@ -1417,6 +1417,11 @@ function M._make_floating_popup_size(contents, opts)
-- make sure borders are always inside the screen
width = math.min(width, screen_width - border_width)
-- Make sure that the width is large enough to fit the title.
if opts.title then
width = math.max(width, vim.fn.strdisplaywidth(opts.title))
end
if wrap_at then
wrap_at = math.min(wrap_at, width)
end

View File

@@ -3528,6 +3528,20 @@ describe('LSP', function()
end)
)
end)
it('considers title when computing width', function()
eq(
{ 17, 2 },
exec_lua(function()
return {
vim.lsp.util._make_floating_popup_size(
{ 'foo', 'bar' },
{ title = 'A very long title' }
),
}
end)
)
end)
end)
describe('lsp.util.trim.trim_empty_lines', function()