From 54e5cb03565ceaa30b152578b3d8791bb9edb29a Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Sun, 23 Jan 2022 02:05:39 +0100 Subject: [PATCH] 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 --- bin/autojump | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/bin/autojump b/bin/autojump index 2b2ec38..aa99be2 100755 --- a/bin/autojump +++ b/bin/autojump @@ -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, ), )