aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/lua/vim/lsp/util.lua5
-rw-r--r--test/functional/plugin/lsp/utils_spec.lua8
2 files changed, 11 insertions, 2 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index a4c8959b99..ec0a1b0ab0 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -1100,13 +1100,14 @@ function M.make_floating_popup_options(width, height, opts)
anchor_below = lines_below > lines_above
end
+ local border_height = get_border_size(opts).height
if anchor_below then
anchor = anchor .. 'N'
- height = math.min(lines_below, height)
+ height = math.max(math.min(lines_below - border_height, height), 0)
row = 1
else
anchor = anchor .. 'S'
- height = math.min(lines_above, height)
+ height = math.max(math.min(lines_above - border_height, height), 0)
row = 0
end
diff --git a/test/functional/plugin/lsp/utils_spec.lua b/test/functional/plugin/lsp/utils_spec.lua
index 12763cfef5..804dc32f0d 100644
--- a/test/functional/plugin/lsp/utils_spec.lua
+++ b/test/functional/plugin/lsp/utils_spec.lua
@@ -212,6 +212,14 @@ describe('vim.lsp.util', function()
it('places window below for anchor_bias = "below"', function ()
assert_anchor('below', 'N')
end)
+
+ it('bordered window truncates dimensions correctly', function ()
+ local opts = exec_lua([[
+ return vim.lsp.util.make_floating_popup_options(100, 100, { border = 'single' })
+ ]])
+
+ eq(56, opts.height)
+ end)
end)
end)