[WIP]: Tue 15 Sep 2020 04:54:27 PM EDT

This commit is contained in:
TJ DeVries
2020-09-15 16:54:27 -04:00
parent b8f17075d4
commit ee94a0db36
9 changed files with 209 additions and 31 deletions
+1
View File
@@ -0,0 +1 @@
return function() return 5 end
+3 -17
View File
@@ -364,25 +364,11 @@ function Picker:find()
log.trace("Processing result... ", entry)
local sort_ok, sort_score = nil, 0
if sorter then
sort_ok, sort_score = pcall(function ()
return sorter:score(prompt, entry)
end)
if not sort_ok then
log.warn("Sorting failed with:", prompt, entry, sort_score)
return
end
if sort_score == -1 then
filtered_amount = filtered_amount + 1
log.trace("Filtering out result: ", entry)
return
end
require('telescope.sorters.multi_thread').score_entry(prompt, entry, self)
else
self.manager:add_entry(0, entry)
end
self.manager:add_entry(sort_score, entry)
end
local process_complete = vim.schedule_wrap(function()
-2
View File
@@ -1,4 +1,3 @@
local log = require('telescope.log')
local util = require('telescope.utils')
local sorters = {}
@@ -65,7 +64,6 @@ sorters.get_levenshtein_sorter = function()
return Sorter:new {
scoring_function = function(_, prompt, line)
local result = require('telescope.algos.string_distance')(prompt, line)
log.info("Sorting result for", prompt, line, " = ", result)
return result
end
}
+30
View File
@@ -0,0 +1,30 @@
local log = require('telescope.log')
local M = {}
function M.score_entry(prompt, entry, picker)
local worker = vim.loop.new_work(function(path, prompt, entry)
package.path = path
if not FuzzySorter then
FuzzySorter = require('telescope.sorters').get_fuzzy_file()
end
-- return pcall(FuzzySorter.score, FuzzySorter, prompt, entry)
return true, 3
end, vim.schedule_wrap(function(score_ok, sort_score)
-- TODO: we should totally make sure that this picker is still doing stuff...
-- it could otherwise be done.
if not score_ok or sort_score == -1 then
log.warn("Sorting failed with:", prompt, entry, sort_score)
return
end
-- picker.manager:add_entry(sort_score, entry)
print(score_ok, sort_score)
end))
worker:queue(package.path, prompt, type(entry) == "string" and entry or entry.ordinal)
end
return M