Skip to content

Commit 54e5cb0

Browse files
committed
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 wting#348
1 parent 4e11af9 commit 54e5cb0

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

bin/autojump

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,15 @@ def find_matches(entries, needles, check_entries=True):
188188
else:
189189
path_exists = lambda _: True
190190

191-
data = sorted(
192-
entries,
193-
key=attrgetter('weight', 'path'),
194-
reverse=True,
195-
)
196-
197191
return ifilter(
198192
lambda entry: not is_cwd(entry) and path_exists(entry),
199-
chain(
200-
match_consecutive(needles, data, ignore_case),
201-
match_fuzzy(needles, data, ignore_case),
202-
match_anywhere(needles, data, ignore_case),
193+
sorted(
194+
set(chain(
195+
match_consecutive(needles, entries, ignore_case),
196+
match_fuzzy(needles, entries, ignore_case),
197+
match_anywhere(needles, entries, ignore_case),
198+
)), key=attrgetter('weight', 'path'),
199+
reverse=True,
203200
),
204201
)
205202

0 commit comments

Comments
 (0)