fix(picker): show_empty for files / grep. Closes #808

This commit is contained in:
Folke Lemaitre 2025-01-31 06:23:08 +01:00
parent ec8eb60515
commit a13ff6fe0f
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 8 additions and 4 deletions

View file

@ -84,7 +84,9 @@ local M = {}
---@field prompt? string prompt text / icon
---@field title? string defaults to a capitalized source name
---@field auto_close? boolean automatically close the picker when focusing another window (defaults to true)
---@field show_empty? boolean show the picker even when there are no items
---@field focus? "input"|"list"|false where to focus when the picker is opened (defaults to "input")
---@field toggles? table<string, string|false|snacks.picker.toggle>
--- Preset options
---@field previewers? snacks.picker.previewers.Config|{}
---@field formatters? snacks.picker.formatters.Config|{}
@ -168,7 +170,6 @@ local defaults = {
reuse_win = false, -- reuse an existing window if the buffer is already open
close = true, -- close the picker when jumping/editing to a location (defaults to true)
},
---@type table<string, string|false|snacks.picker.toggle>
toggles = {
follow = "f",
hidden = "h",

View file

@ -161,6 +161,7 @@ M.diagnostics_buffer = {
M.files = {
finder = "files",
format = "file",
show_empty = true,
hidden = false,
ignored = false,
follow = false,
@ -189,6 +190,7 @@ M.git_branches = {
---@field submodules? boolean show submodule files
M.git_files = {
finder = "git_files",
show_empty = true,
format = "file",
untracked = false,
submodules = false,
@ -270,11 +272,12 @@ M.grep = {
finder = "grep",
regex = true,
format = "file",
show_empty = true,
live = true, -- live grep by default
supports_live = true,
}
---@type snacks.picker.grep.Config
---@type snacks.picker.grep.Config|{}
M.grep_buffers = {
finder = "grep",
format = "file",
@ -284,7 +287,7 @@ M.grep_buffers = {
supports_live = true,
}
---@type snacks.picker.grep.Config
---@type snacks.picker.grep.Config|{}
M.grep_word = {
finder = "grep",
format = "file",

View file

@ -639,7 +639,7 @@ function M:update()
if self.opts.live then
self:show()
elseif not self:is_active() then
if count == 0 then
if count == 0 and not self.opts.show_empty then
-- no results found
local msg = "No results"
if self.opts.source then