Skip to content

Commit

Permalink
bin/autojump: Make the test pass
Browse files Browse the repository at this point in the history
The order of completion suggestions must be according to the weights,
yet `set` is unordered. Thus, sorting needs to be performed after
de-duplicating.

Fixes #348
  • Loading branch information
rico-chet committed Feb 8, 2022
1 parent 4e11af9 commit 54e5cb0
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions bin/autojump
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,15 @@ def find_matches(entries, needles, check_entries=True):
else:
path_exists = lambda _: True

data = sorted(
entries,
key=attrgetter('weight', 'path'),
reverse=True,
)

return ifilter(
lambda entry: not is_cwd(entry) and path_exists(entry),
chain(
match_consecutive(needles, data, ignore_case),
match_fuzzy(needles, data, ignore_case),
match_anywhere(needles, data, ignore_case),
sorted(
set(chain(
match_consecutive(needles, entries, ignore_case),
match_fuzzy(needles, entries, ignore_case),
match_anywhere(needles, entries, ignore_case),
)), key=attrgetter('weight', 'path'),
reverse=True,
),
)

Expand Down

0 comments on commit 54e5cb0

Please sign in to comment.