summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorSenghan Bright <senghan.bright@deltaprojects.com>2021-01-28 22:39:05 +0100
committerGitHub <noreply@github.com>2021-01-28 16:39:05 -0500
commit9d4670c74898c6050546580c71211746b9bb8aa7 (patch)
tree26c8676ed3fd561890a2e59bfc69ccd43a01d5c1 /lua
parent5995a8be8faaa2c6e8693ca52f2320cb4a80e3fa (diff)
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>
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/finders.lua4
-rw-r--r--lua/telescope/pickers.lua13
2 files changed, 15 insertions, 2 deletions
diff --git a/lua/telescope/finders.lua b/lua/telescope/finders.lua
index 7bc4ec5..cf616b0 100644
--- a/lua/telescope/finders.lua
+++ b/lua/telescope/finders.lua
@@ -11,6 +11,8 @@ local _callable_obj = function()
obj.__index = obj
obj.__call = function(t, ...) return t:_find(...) end
+ obj.close = function() end
+
return obj
end
@@ -33,7 +35,7 @@ local JobFinder = _callable_obj()
function JobFinder:new(opts)
opts = opts or {}
-> assert(not opts.results, "`results` should be used with finder.new_table")
+ assert(not opts.results, "`results` should be used with finder.new_table")
assert(not opts.static, "`static` should be used with finder.new_oneshot_job")
local obj = setmetatable({
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua
index 4165ec5..403371f 100644
--- a/lua/telescope/pickers.lua
+++ b/lua/telescope/pickers.lua
@@ -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