Skip to content

Commit

Permalink
feat(pickers): custom results height for centered layout
Browse files Browse the repository at this point in the history
  • Loading branch information
ribru17 committed Feb 5, 2024
1 parent 2360838 commit 2256666
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/telescope/pickers/layout_strategies.lua
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ layout_strategies.center = make_documented_layout(
"center",
vim.tbl_extend("error", shared_options, {
preview_cutoff = "When lines are less than this value, the preview will be disabled",
results_height = "Optional height specifically for results window",
}),
function(self, max_columns, max_lines, layout_config)
local initial_options = p_window.get_initial_window_options(self)
Expand Down Expand Up @@ -520,6 +521,13 @@ layout_strategies.center = make_documented_layout(
preview.line = preview.line + 1
end

if layout_config.results_height then
local diff = results.height - resolve.resolve_height(layout_config.results_height)(self, max_columns, max_lines)
results.height = results.height - diff
results.line = results.line + diff
preview.height = preview.height + diff
end

return {
preview = self.previewer and preview.height > 0 and preview,
results = results,
Expand Down

0 comments on commit 2256666

Please sign in to comment.