lsp: compute height of floating preview correctly for wrapped lines (#12380)

* take wrapping into account when computing float height

* factor out size calculation

* add test

* accept and pass through opts.wrap_at in floating_preview

* make padding configurable

* slightly refactor fancy_floating_markdown to make use of make_position

* padding using string.format

* move trim and pad to separate function

* nit

Co-authored-by: Hirokazu Hata <h.hata.ai.t@gmail.com>

* remove mention of backward compat

* make lint happy

Co-authored-by: Hirokazu Hata <h.hata.ai.t@gmail.com>
This commit is contained in:
Christian Clason
2020-06-04 20:23:03 +02:00
committed by GitHub
parent 6f4f38cd54
commit b7f3f11049
2 changed files with 132 additions and 38 deletions

View File

@@ -1379,4 +1379,14 @@ describe('LSP', function()
eq('å', exec_lua[[return vim.fn.expand('<cword>')]])
end)
end)
describe('lsp.util._make_floating_popup_size', function()
exec_lua [[ contents =
{"text tαxt txtα tex",
"text tααt tααt text",
"text tαxt tαxt"}
]]
eq({19,3}, exec_lua[[ return {vim.lsp.util._make_floating_popup_size(contents)} ]])
eq({15,5}, exec_lua[[ return {vim.lsp.util._make_floating_popup_size(contents,{width = 15, wrap_at = 14})} ]])
end)
end)