mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 20:08:17 +00:00
fix(float): ensure floating window width can fit title
This commit is contained in:

committed by
Lewis Russell

parent
f932c7852e
commit
d2cca606a1
@@ -1417,6 +1417,11 @@ function M._make_floating_popup_size(contents, opts)
|
|||||||
-- make sure borders are always inside the screen
|
-- make sure borders are always inside the screen
|
||||||
width = math.min(width, screen_width - border_width)
|
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
|
if wrap_at then
|
||||||
wrap_at = math.min(wrap_at, width)
|
wrap_at = math.min(wrap_at, width)
|
||||||
end
|
end
|
||||||
|
@@ -3528,6 +3528,20 @@ describe('LSP', function()
|
|||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
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)
|
end)
|
||||||
|
|
||||||
describe('lsp.util.trim.trim_empty_lines', function()
|
describe('lsp.util.trim.trim_empty_lines', function()
|
||||||
|
Reference in New Issue
Block a user