feat: add preview width option for bottom_pane layout (#1505)
* feat(layout_strategies): started adding preview width for bottom pane * fix(bottom_pane preview_width): fixed some values and added defualt * fix(config): better default for preview cutoff * fix(layout): removed unnecessary variable value
This commit is contained in:
@@ -778,6 +778,7 @@ end)
|
||||
layout_strategies.bottom_pane = make_documented_layout(
|
||||
"bottom_pane",
|
||||
vim.tbl_extend("error", shared_options, {
|
||||
preview_width = { "Change the width of Telescope's preview window", "See |resolver.resolve_width()|" },
|
||||
prompt_position = { "Where to place prompt window.", "Available Values: 'bottom', 'top'" },
|
||||
}),
|
||||
function(self, max_columns, max_lines, layout_config)
|
||||
@@ -806,13 +807,20 @@ layout_strategies.bottom_pane = make_documented_layout(
|
||||
results.height = height - prompt.height - (2 * bs)
|
||||
preview.height = results.height - bs
|
||||
|
||||
local width
|
||||
|
||||
-- Width
|
||||
prompt.width = max_columns - 2 * bs
|
||||
-- TODO(l-kershaw): add a preview_cutoff option
|
||||
if self.previewer then
|
||||
-- TODO(l-kershaw): make configurable
|
||||
results.width = math.floor(max_columns / 2) - 2 * bs
|
||||
preview.width = max_columns - results.width - 4 * bs
|
||||
local w_space
|
||||
if self.previewer and max_columns >= layout_config.preview_cutoff then
|
||||
-- Cap over/undersized width (with preview)
|
||||
width, w_space = calc_size_and_spacing(max_columns, max_columns, bs, 2, 4, 0)
|
||||
|
||||
preview.width = resolve.resolve_width(if_nil(layout_config.preview_width, function(_, _)
|
||||
-- By default, previewer takes 1/2 of the layout
|
||||
return math.floor(width / 2)
|
||||
end))(self, width, max_lines)
|
||||
results.width = width - preview.width - w_space
|
||||
else
|
||||
results.width = prompt.width
|
||||
preview.width = 0
|
||||
|
||||
Reference in New Issue
Block a user