feat: Do a bit better sorting for command history

To be honest, I'm not 100% sure this is fantastic, but it's definitely a
step in the right direction for command history.

Closes: #150
This commit is contained in:
TJ DeVries
2020-10-08 22:31:44 -04:00
parent 7938ace0f6
commit 59497d6640
6 changed files with 59 additions and 29 deletions

View File

@@ -33,7 +33,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({
@@ -238,8 +238,11 @@ function StaticFinder:new(opts)
assert(type(input_results) == 'table', "self.results must be a table")
local results = {}
for _, v in ipairs(input_results) do
table.insert(results, entry_maker(v))
for k, v in ipairs(input_results) do
local entry = entry_maker(v)
entry.index = k
table.insert(results, entry)
end
return setmetatable({ results = results }, self)