From 0e901f8c68a7da573487c16506acb3a49371ddf1 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Mon, 12 Sep 2022 14:28:16 +0200 Subject: [PATCH] Shell: Sort CompletionSuggestions for paths lexicographically This used to be ordered by inode, which can be surprising. --- Userland/Shell/Shell.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index add8fb4977..bb3aad9f42 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -1519,6 +1519,10 @@ Vector Shell::complete_path(StringView base, StringV } } + // The results of DirIterator are in the order they appear on-disk. + // Instead, return suggestions in lexicographical order. + quick_sort(suggestions, [](auto& a, auto& b) { return a.text_string < b.text_string; }); + return suggestions; }