From b7f3f11049c6847a2b0c4bbd89e8339036e00da6 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 4 Jun 2020 20:23:03 +0200 Subject: 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 * remove mention of backward compat * make lint happy Co-authored-by: Hirokazu Hata --- test/functional/plugin/lsp_spec.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/functional/plugin') diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 479741d717..ae436360c3 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -1379,4 +1379,14 @@ describe('LSP', function() eq('å', exec_lua[[return vim.fn.expand('')]]) 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) -- cgit