aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-10-12 15:39:39 +0800
committerGitHub <noreply@github.com>2023-10-12 15:39:39 +0800
commit840e1864c2de2b4b192a4df1865b69093904b139 (patch)
treef5c746500e0b7880e1fcc1288c38c662d130fbcb /runtime/lua/vim/lsp/util.lua
parentd2d38858d1f33a2cd92e9a6182ece2459b0d6f75 (diff)
downloadrneovim-840e1864c2de2b4b192a4df1865b69093904b139.tar.gz
rneovim-840e1864c2de2b4b192a4df1865b69093904b139.tar.bz2
rneovim-840e1864c2de2b4b192a4df1865b69093904b139.zip
fix(lsp): handle NUL bytes in popup text (#25612)
Fix #25610
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua4
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index ec0a1b0ab0..7e6855528a 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1647,7 +1647,7 @@ function M._make_floating_popup_size(contents, opts)
width = 0
for i, line in ipairs(contents) do
-- TODO(ashkan) use nvim_strdisplaywidth if/when that is introduced.
- line_widths[i] = vim.fn.strdisplaywidth(line)
+ line_widths[i] = vim.fn.strdisplaywidth(line:gsub('%z', '\n'))
width = math.max(line_widths[i], width)
end
end
@@ -1676,7 +1676,7 @@ function M._make_floating_popup_size(contents, opts)
height = 0
if vim.tbl_isempty(line_widths) then
for _, line in ipairs(contents) do
- local line_width = vim.fn.strdisplaywidth(line)
+ local line_width = vim.fn.strdisplaywidth(line:gsub('%z', '\n'))
height = height + math.ceil(line_width / wrap_at)
end
else