feat: allow a callback to be called on on_lines update (for filtering tags from query text) (#455)
* allow a callback to be called on on_lines update * . * remove unused _filter_marker var * nit: Move to table and implement 'close' Co-authored-by: TJ DeVries <devries.timothyj@gmail.com>
This commit is contained in:
@@ -76,6 +76,7 @@ function Picker:new(opts)
|
||||
|
||||
default_text = opts.default_text,
|
||||
get_status_text = get_default(opts.get_status_text, config.values.get_status_text),
|
||||
_on_input_filter_cb = opts.on_input_filter_cb or function() end,
|
||||
|
||||
finder = opts.finder,
|
||||
sorter = opts.sorter,
|
||||
@@ -445,7 +446,17 @@ function Picker:find()
|
||||
return
|
||||
end
|
||||
|
||||
local prompt = self:_get_prompt()
|
||||
local original_prompt = self:_get_prompt()
|
||||
local on_input_result = self._on_input_filter_cb(original_prompt) or {}
|
||||
|
||||
local prompt = on_input_result.prompt or original_prompt
|
||||
local finder = on_input_result.updated_finder
|
||||
|
||||
if finder then
|
||||
self.finder:close()
|
||||
self.finder = finder
|
||||
end
|
||||
|
||||
if self.sorter then
|
||||
self.sorter:_start(prompt)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user