neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit d2cca606a1b67a7e9e093154449f35eaacab0532
parent f932c7852e014bf608abdb617fb10dfc464ca9bc
Author: Maria José Solano <majosolano99@gmail.com>
Date:   Sat, 22 Feb 2025 13:19:00 -0800

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

Diffstat:
Mruntime/lua/vim/lsp/util.lua | 5+++++
Mtest/functional/plugin/lsp_spec.lua | 14++++++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)

diff --git 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 @@ -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()