bin/autojump: Make the test pass

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 https://github.com/wting/autojump/issues/348
pull/646/head
Alex Thiessen 2 years ago
parent 4e11af9f12
commit 54e5cb0356
No known key found for this signature in database
GPG Key ID: 6C90AE2B18A1CF5B

@ -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,
),
)

Loading…
Cancel
Save