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:
Senghan Bright
2021-01-28 22:39:05 +01:00
committed by GitHub
parent 5995a8be8f
commit 9d4670c748
2 changed files with 15 additions and 2 deletions

View File

@@ -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