fix: Respect cmdheight and laststatus

This commit is contained in:
TJ DeVries
2020-10-08 12:53:42 -04:00
parent 8736ea5f6a
commit 9d894f8229
3 changed files with 22 additions and 10 deletions

View File

@@ -98,7 +98,7 @@ local _resolve_map = {
end,
-- Percentages
[function(val) return type(val) == 'number' and val > 0 and val < 1 end] = function(selector, val)
[function(val) return type(val) == 'number' and val >= 0 and val < 1 end] = function(selector, val)
return function(...)
return math.floor(val * select(selector, ...))
end

View File

@@ -280,7 +280,12 @@ function Picker:find()
-- 1. Prompt window
-- 2. Options window
-- 3. Preview window
local popup_opts = self:get_window_options(vim.o.columns, vim.o.lines)
local line_count = vim.o.lines - vim.o.cmdheight
if vim.o.laststatus ~= 0 then
line_count = line_count - 1
end
local popup_opts = self:get_window_options(vim.o.columns, line_count)
-- `popup.nvim` massaging so people don't have to remember minheight shenanigans
popup_opts.results.minheight = popup_opts.results.height

View File

@@ -215,18 +215,25 @@ layout_strategies.vertical = function(self, max_columns, max_lines)
prompt.width = width
-- Height
local height_padding = resolve.resolve_height(layout_config.height_padding or 3)(self, max_columns, max_lines)
local height_padding = math.max(
1,
resolve.resolve_height(layout_config.height_padding or 3)(self, max_columns, max_lines)
)
local picker_height = max_lines - 2 * height_padding
results.height = resolve.resolve_height(layout_config.results_height or 10)(self, max_columns, max_lines)
prompt.height = 1
-- The last 2 * 2 is for the extra borders
local preview_total = 0
preview.height = 0
if self.previewer then
preview.height = max_lines - results.height - prompt.height - 2 * 2 - height_padding * 2
else
results.height = max_lines - prompt.height - 2 - height_padding * 2
preview.height = resolve.resolve_height(
layout_config.preview_height or (max_lines - 15)
)(self, max_columns, picker_height)
preview_total = preview.height + 2
end
prompt.height = 1
results.height = picker_height - preview_total - prompt.height - 2
results.col, preview.col, prompt.col = width_padding, width_padding, width_padding
if self.previewer then