feat: default cut off for preview
This commit is contained in:
@@ -44,7 +44,7 @@ function Picker:new(opts)
|
|||||||
}, Picker)
|
}, Picker)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Picker:get_window_options(max_columns, max_lines, prompt_title)
|
function Picker:get_window_options(max_columns, max_lines, prompt_title, find_options)
|
||||||
local preview = {
|
local preview = {
|
||||||
border = {},
|
border = {},
|
||||||
enter = false,
|
enter = false,
|
||||||
@@ -63,7 +63,7 @@ function Picker:get_window_options(max_columns, max_lines, prompt_title)
|
|||||||
-- TODO: Test with 120 width terminal
|
-- TODO: Test with 120 width terminal
|
||||||
|
|
||||||
local width_padding = 10
|
local width_padding = 10
|
||||||
if not self.previewer then
|
if not self.previewer or max_columns < find_options.preview_cutoff then
|
||||||
preview.width = 0
|
preview.width = 0
|
||||||
elseif max_columns < 150 then
|
elseif max_columns < 150 then
|
||||||
width_padding = 5
|
width_padding = 5
|
||||||
@@ -107,15 +107,20 @@ function Picker:get_window_options(max_columns, max_lines, prompt_title)
|
|||||||
preview.line = results.line
|
preview.line = results.line
|
||||||
|
|
||||||
return {
|
return {
|
||||||
preview = self.previewer and preview,
|
preview = preview.width > 0 and preview,
|
||||||
results = results,
|
results = results,
|
||||||
prompt = prompt,
|
prompt = prompt,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- opts.preview_cutoff = 120
|
||||||
function Picker:find(opts)
|
function Picker:find(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
|
if opts.preview_cutoff == nil then
|
||||||
|
opts.preview_cutoff = 120
|
||||||
|
end
|
||||||
|
|
||||||
local finder = opts.finder
|
local finder = opts.finder
|
||||||
assert(finder, "Finder is required to do picking")
|
assert(finder, "Finder is required to do picking")
|
||||||
|
|
||||||
@@ -128,7 +133,7 @@ function Picker:find(opts)
|
|||||||
-- 1. Prompt window
|
-- 1. Prompt window
|
||||||
-- 2. Options window
|
-- 2. Options window
|
||||||
-- 3. Preview window
|
-- 3. Preview window
|
||||||
local popup_opts = self:get_window_options(vim.o.columns, vim.o.lines, prompt_string)
|
local popup_opts = self:get_window_options(vim.o.columns, vim.o.lines, prompt_string, opts)
|
||||||
|
|
||||||
-- TODO: Add back the borders after fixing some stuff in popup.nvim
|
-- TODO: Add back the borders after fixing some stuff in popup.nvim
|
||||||
local results_win, results_opts = popup.create('', popup_opts.results)
|
local results_win, results_opts = popup.create('', popup_opts.results)
|
||||||
|
|||||||
Reference in New Issue
Block a user