fix: Think I fixed the weird movements
This commit is contained in:
@@ -72,7 +72,7 @@ function Finder:_find(prompt, process_result, process_complete)
|
||||
self.job:shutdown()
|
||||
end
|
||||
|
||||
log.info("Finding...")
|
||||
log.trace("Finding...")
|
||||
if self.static and self.done then
|
||||
log.info("Using previous results")
|
||||
for _, v in ipairs(self._cached_lines) do
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
return require('plenary.log').new {
|
||||
plugin = 'telescope',
|
||||
level = 'debug',
|
||||
level = 'info',
|
||||
}
|
||||
|
||||
@@ -237,28 +237,21 @@ function Picker:find(opts)
|
||||
self.manager:add_entry(sort_score, entry)
|
||||
end
|
||||
|
||||
local process_complete = vim.schedule_wrap(function()
|
||||
local process_complete = function()
|
||||
self:set_selection(self:get_selection_row())
|
||||
|
||||
local worst_line = self.max_results - self.manager.num_results()
|
||||
if worst_line == 0 then
|
||||
if worst_line <= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local empty_lines = utils.repeated_table(worst_line, "")
|
||||
vim.api.nvim_buf_set_lines(results_bufnr, 0, worst_line, false, empty_lines)
|
||||
vim.schedule(function()
|
||||
local empty_lines = utils.repeated_table(worst_line, "")
|
||||
vim.api.nvim_buf_set_lines(results_bufnr, 0, worst_line, false, empty_lines)
|
||||
|
||||
log.debug("Worst Line after process_complete: %s", worst_line, results_bufnr)
|
||||
|
||||
-- local fun = require('fun')
|
||||
-- local zip = fun.zip
|
||||
-- local tomap = fun.tomap
|
||||
|
||||
-- log.trace("%s", tomap(zip(
|
||||
-- a.nvim_buf_get_lines(results_bufnr, worst_line, self.max_results, false),
|
||||
-- self.line_scores
|
||||
-- )))
|
||||
end)
|
||||
log.trace("Worst Line after process_complete: %s", worst_line, results_bufnr)
|
||||
end)
|
||||
end
|
||||
|
||||
local ok, msg = pcall(function()
|
||||
return finder(prompt, process_result, process_complete)
|
||||
|
||||
@@ -222,6 +222,15 @@ describe('Sorters', function()
|
||||
assert(exact_match < ok_match)
|
||||
assert(ok_match < no_match)
|
||||
end)
|
||||
|
||||
it('sorts multiple finds better', function()
|
||||
local sorter = require('telescope.sorters').get_norcalli_sorter()
|
||||
|
||||
local multi_match = sorter:score('generics', 'exercises/generics/generics2.rs')
|
||||
local one_match = sorter:score('abcdef', 'exercises/generics/README.md')
|
||||
|
||||
assert(multi_match < one_match)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user