Skip to content

Commit

Permalink
feat: support source priority
Browse files Browse the repository at this point in the history
fixes #30
  • Loading branch information
max397574 committed Aug 2, 2024
1 parent 08fe40a commit ef5d683
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lua/care/sorter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function sorter.sort(entries, prefix)

for _, res in ipairs(fzy.filter(prefix, filter_texts)) do
-- res is a table like `{2, {1, 5, 9}, 2.63}` {<index>, {<matches>}, <score>}
-- priority * 10 because fzy scores aren't always between 0 and 1 but quire likely between 0 and 10
entries[res[1]].score = res[3]
+ (entries[res[1]].source.config.priority and (entries[res[1]].source.config.priority * 10) or 0)
entries[res[1]].matches = res[2]
end
entries = vim.iter(entries)
Expand Down

0 comments on commit ef5d683

Please sign in to comment.