summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-08-27 23:41:17 -0400
committerTJ DeVries <devries.timothyj@gmail.com>2020-08-27 23:41:17 -0400
commitd20be453a82b7fc6e54c8424133218b4032962a7 (patch)
tree759e44837661fd8d6928c46f25b8e88244165068 /lua
parent5eb1971dd89b11c8262d8857435944be2832ee85 (diff)
feat: default cut off for preview
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/pickers.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua
index b9f0010..3b70235 100644
--- a/lua/telescope/pickers.lua
+++ b/lua/telescope/pickers.lua
@@ -44,7 +44,7 @@ function Picker:new(opts)
}, Picker)
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 = {
border = {},
enter = false,
@@ -63,7 +63,7 @@ function Picker:get_window_options(max_columns, max_lines, prompt_title)
-- TODO: Test with 120 width terminal
local width_padding = 10
- if not self.previewer then
+ if not self.previewer or max_columns < find_options.preview_cutoff then
preview.width = 0
elseif max_columns < 150 then
width_padding = 5
@@ -107,15 +107,20 @@ function Picker:get_window_options(max_columns, max_lines, prompt_title)
preview.line = results.line
return {
- preview = self.previewer and preview,
+ preview = preview.width > 0 and preview,
results = results,
prompt = prompt,
}
end
+-- opts.preview_cutoff = 120
function Picker:find(opts)
opts = opts or {}
+ if opts.preview_cutoff == nil then
+ opts.preview_cutoff = 120
+ end
+
local finder = opts.finder
assert(finder, "Finder is required to do picking")
@@ -128,7 +133,7 @@ function Picker:find(opts)
-- 1. Prompt window
-- 2. Options 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
local results_win, results_opts = popup.create('', popup_opts.results)