diff --git a/lua/telescope/config/resolve.lua b/lua/telescope/config/resolve.lua index 986fff7..1e1c68a 100644 --- a/lua/telescope/config/resolve.lua +++ b/lua/telescope/config/resolve.lua @@ -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 diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index 6f16ed6..eec61a0 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -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 diff --git a/lua/telescope/pickers/layout_strategies.lua b/lua/telescope/pickers/layout_strategies.lua index f823da8..b43466c 100644 --- a/lua/telescope/pickers/layout_strategies.lua +++ b/lua/telescope/pickers/layout_strategies.lua @@ -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