mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
@@ -1647,7 +1647,7 @@ function M._make_floating_popup_size(contents, opts)
|
|||||||
width = 0
|
width = 0
|
||||||
for i, line in ipairs(contents) do
|
for i, line in ipairs(contents) do
|
||||||
-- TODO(ashkan) use nvim_strdisplaywidth if/when that is introduced.
|
-- 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)
|
width = math.max(line_widths[i], width)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1676,7 +1676,7 @@ function M._make_floating_popup_size(contents, opts)
|
|||||||
height = 0
|
height = 0
|
||||||
if vim.tbl_isempty(line_widths) then
|
if vim.tbl_isempty(line_widths) then
|
||||||
for _, line in ipairs(contents) do
|
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)
|
height = height + math.ceil(line_width / wrap_at)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@@ -3069,6 +3069,18 @@ describe('LSP', function()
|
|||||||
it('calculates size correctly with wrapping', function()
|
it('calculates size correctly with wrapping', function()
|
||||||
eq({15,5}, exec_lua[[ return {vim.lsp.util._make_floating_popup_size(contents,{width = 15, wrap_at = 14})} ]])
|
eq({15,5}, exec_lua[[ return {vim.lsp.util._make_floating_popup_size(contents,{width = 15, wrap_at = 14})} ]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('handles NUL bytes in text', function()
|
||||||
|
exec_lua([[ contents = {
|
||||||
|
'\000\001\002\003\004\005\006\007\008\009',
|
||||||
|
'\010\011\012\013\014\015\016\017\018\019',
|
||||||
|
'\020\021\022\023\024\025\026\027\028\029',
|
||||||
|
} ]])
|
||||||
|
command('set list listchars=')
|
||||||
|
eq({20,3}, exec_lua[[ return {vim.lsp.util._make_floating_popup_size(contents)} ]])
|
||||||
|
command('set display+=uhex')
|
||||||
|
eq({40,3}, exec_lua[[ return {vim.lsp.util._make_floating_popup_size(contents)} ]])
|
||||||
|
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