summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2021-08-20 13:12:29 -0400
committerGitHub <noreply@github.com>2021-08-20 13:12:29 -0400
commitbc470fe59f8157f22e1bbd1cea8d395a5c859d0b (patch)
tree469b71ba3d5b6e29312e52c6d487ef30aa6bf5bd /lua
parentb47bb8df1eef6431a1321a05f9c5eef95d4602bb (diff)
fix(sorters): fix sorters running after destroy, which can segfault (#1137)
* fix(sorters): fix sorters running after destroy, which can segfault * fixup: Only check when we've set a status
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/sorters.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/lua/telescope/sorters.lua b/lua/telescope/sorters.lua
index ba38e2d..c3c584c 100644
--- a/lua/telescope/sorters.lua
+++ b/lua/telescope/sorters.lua
@@ -54,6 +54,7 @@ function Sorter:new(opts)
start = opts.start,
finish = opts.finish,
destroy = opts.destroy,
+ _status = nil,
filter_function = opts.filter_function,
scoring_function = opts.scoring_function,
@@ -67,12 +68,14 @@ function Sorter:new(opts)
end
function Sorter:_init()
+ self._status = "init"
if self.init then
self:init()
end
end
function Sorter:_destroy()
+ self._status = "destroy"
if self.destroy then
self:destroy()
end
@@ -84,6 +87,7 @@ end
-- as he did in his example.
-- Example can be found in ./scratch/prime_prompt_cache.lua
function Sorter:_start(prompt)
+ self._status = "start"
if self.start then
self:start(prompt)
end
@@ -107,6 +111,7 @@ function Sorter:_start(prompt)
end
function Sorter:_finish(prompt)
+ self._status = "finish"
if self.finish then
self:finish(prompt)
end
@@ -119,6 +124,10 @@ function Sorter:score(prompt, entry, cb_add, cb_filter)
return
end
+ if self._status and self._status ~= "start" then
+ return
+ end
+
local ordinal = entry.ordinal
if self:_was_discarded(prompt, ordinal) then
return cb_filter(entry)