From 38a7c77e4b932822fbbe54825de64882e88dd569 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Mon, 10 Jun 2019 18:50:40 +0200 Subject: [PATCH] Re-double-super-fix tilde completion crash Yeah, I was too clever with the operators here. Fixes #5929. --- src/complete.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/complete.cpp b/src/complete.cpp index 281a5a9db..c712b6b2c 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -243,9 +243,15 @@ static bool compare_completions_by_duplicate_arguments(const completion_t &a, } static bool compare_completions_by_tilde(const completion_t &a, const completion_t &b) { - return (a.completion.empty() < b.completion.empty()) || - (a.completion.back() == L'~') < (b.completion.back() == L'~'); + if (a.completion.empty()) { + return false; + } + if (b.completion.empty()) { + return true; + } + return ((a.completion.back() == L'~') < (b.completion.back() == L'~')); } + /// Unique the list of completions, without perturbing their order. static void unique_completions_retaining_order(std::vector *comps) { std::unordered_set seen;