mirror of
https://github.com/zoriya/telescope.nvim.git
synced 2026-06-07 04:35:03 +00:00
[WIP]: Tue 15 Sep 2020 04:54:27 PM EDT
This commit is contained in:
@@ -0,0 +1 @@
|
||||
return function() return 5 end
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user