diff options
author | Au. <acehinnnqru@gmail.com> | 2025-03-22 10:43:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-22 10:43:06 +0800 |
commit | 5187be81c2eb2de6793a0f9d57d0f2d95f356d22 (patch) | |
tree | f3eaa80d53564c379a25be940139f1570986c7de /runtime/lua/vim/lsp/util.lua | |
parent | b165ad067101df29636203ff104a2586f5df1413 (diff) | |
download | rneovim-5187be81c2eb2de6793a0f9d57d0f2d95f356d22.tar.gz rneovim-5187be81c2eb2de6793a0f9d57d0f2d95f356d22.tar.bz2 rneovim-5187be81c2eb2de6793a0f9d57d0f2d95f356d22.zip |
fix(lsp): handle using array as open_floating_preview title (#33016)
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index d8a6a70ccd..a069225e37 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1411,10 +1411,16 @@ function M._make_floating_popup_size(contents, opts) 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)) + local title_length = 0 + local chunks = type(opts.title) == 'string' and { { opts.title } } or opts.title or {} + for _, chunk in + ipairs(chunks --[=[@as [string, string][]]=]) + do + title_length = title_length + vim.fn.strdisplaywidth(chunk[1]) end + width = math.max(width, title_length) + if wrap_at then wrap_at = math.min(wrap_at, width) end @@ -1490,7 +1496,7 @@ end --- @field offset_y? integer --- @field border? string|(string|[string,string])[] override `border` --- @field zindex? integer override `zindex`, defaults to 50 ---- @field title? string +--- @field title? string|[string,string][] --- @field title_pos? 'left'|'center'|'right' --- --- (default: `'cursor'`) |