Skip to content

Commit f745b61

Browse files
jamestrewConni2461
authored andcommitted
fix(previewer): preview=false option inheritance
According to `:h telescope.defaults.preview`, we should be able to do `preview=false` to disable the previewer for pickers. With how picker options resolve inheritance, something like this should work. ```lua require('telescope').setup { defaults = { preview = true }, pickers = { find_files = { preview = false } } } ``` Here, find_files should not show a previewer but it previously would. Corrects this by checking if `opts.preview` is explicitly set to `false`. In which case, we won't show the previewer. Closes #3325
1 parent 01419c1 commit f745b61

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lua/telescope/command.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ command.convert_user_opts = function(user_opts)
112112
user_opts[key] = eval
113113
else
114114
-- otherwise return nil (allows split check later)
115+
-- BUG: this doesn't allow things like `preview=false`, where an
116+
-- option supports other types other than the default type
117+
-- (`preview` has a default type of table)
115118
user_opts[key] = nil
116119
end
117120
end

lua/telescope/previewers/buffer_previewer.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ local function defaulter(f, default_opts)
3636
default_opts = default_opts or {}
3737
return {
3838
new = function(opts)
39+
if opts.preview == false then
40+
return false
41+
end
3942
if conf.preview == false and not opts.preview then
4043
return false
4144
end

0 commit comments

Comments
 (0)