summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorfdschmidt93 <39233597+fdschmidt93@users.noreply.github.com>2021-09-30 15:53:06 +0200
committerGitHub <noreply@github.com>2021-09-30 15:53:06 +0200
commit440c598de419858a056e7d9d42a0a6829cd5bb05 (patch)
treec681f5458896c5b049eee7225a7a8050b4cd6204 /lua
parent4e629cdea197b7c4f3c476346a8841b74bf9fd56 (diff)
fix: which key float positioning (#1293)
* Adjust which key float positioning for recent plenary and telescope theme changes
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/actions/init.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua
index 2dd4fb0..91ba554 100644
--- a/lua/telescope/actions/init.lua
+++ b/lua/telescope/actions/init.lua
@@ -1026,10 +1026,16 @@ actions.which_key = function(prompt_bufnr, opts)
local winheight = opts.num_rows + 2 * opts.line_padding
-- place hints at top or bottom relative to prompt
+ local win_central_row = function(win_nr)
+ return a.nvim_win_get_position(win_nr)[1] + 0.5 * a.nvim_win_get_height(win_nr)
+ end
+ -- TODO(fdschmidt93|l-kershaw): better generalization of where to put which key float
local picker = action_state.get_current_picker(prompt_bufnr)
- local prompt_win = picker.prompt_win
- local prompt_row = a.nvim_win_get_position(prompt_win)[1]
- local prompt_pos = prompt_row <= 0.5 * vim.o.lines
+ local prompt_row = win_central_row(picker.prompt_win)
+ local results_row = win_central_row(picker.results_win)
+ local preview_row = win_central_row(picker.preview_win)
+ local prompt_pos = prompt_row < 0.4 * vim.o.lines
+ or prompt_row < 0.6 * vim.o.lines and results_row + preview_row < vim.o.lines
local modes = { n = "Normal", i = "Insert" }
local title_mode = opts.only_show_current_mode and modes[mode] .. " Mode " or ""
@@ -1041,8 +1047,8 @@ actions.which_key = function(prompt_bufnr, opts)
maxwidth = vim.o.columns,
minheight = winheight,
maxheight = winheight,
- line = prompt_pos == true and vim.o.lines - winheight or 0,
- col = 1,
+ line = prompt_pos == true and vim.o.lines - winheight + 1 or 1,
+ col = 0,
border = { prompt_pos and 1 or 0, 0, not prompt_pos and 1 or 0, 0 },
borderchars = { prompt_pos and "─" or " ", "", not prompt_pos and "─" or " ", "", "", "", "", "" },
noautocmd = true,