aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 4a781359d4..0de5fdad46 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -264,11 +264,16 @@ function M.make_floating_popup_options(width, height, opts)
local anchor = ''
local row, col
- if vim.fn.winline() <= height then
+ local lines_above = vim.fn.winline() - 1
+ local lines_below = vim.fn.winheight(0) - lines_above
+
+ if lines_above < lines_below then
anchor = anchor..'N'
+ height = math.min(lines_below, height)
row = 1
else
anchor = anchor..'S'
+ height = math.min(lines_above, height)
row = 0
end