aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria José Solano <majosolano99@gmail.com>2025-02-22 13:19:00 -0800
committerLewis Russell <me@lewisr.dev>2025-02-23 10:32:20 +0000
commitd2cca606a1b67a7e9e093154449f35eaacab0532 (patch)
tree1a36395bc7da09ff28d6c68a52dc6939b174a000
parentf932c7852e014bf608abdb617fb10dfc464ca9bc (diff)
downloadrneovim-d2cca606a1b67a7e9e093154449f35eaacab0532.tar.gz
rneovim-d2cca606a1b67a7e9e093154449f35eaacab0532.tar.bz2
rneovim-d2cca606a1b67a7e9e093154449f35eaacab0532.zip
fix(float): ensure floating window width can fit title
-rw-r--r--runtime/lua/vim/lsp/util.lua5
-rw-r--r--test/functional/plugin/lsp_spec.lua14
2 files changed, 19 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 9e84e27205..905b9822ba 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -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
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index a0064f741e..17e3fbbf70 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -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()