From e9a2060b279788ab51312c5dea0bdf20ff70fda2 Mon Sep 17 00:00:00 2001 From: ajreckof <66184050+ajreckof@users.noreply.github.com> Date: Fri, 16 Jun 2023 11:16:33 +0200 Subject: [PATCH] Fix wrong alphabetical order in autocompletion sorting. Co-Authored-By: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> --- core/object/script_language.h | 2 +- scene/gui/code_edit.cpp | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/object/script_language.h b/core/object/script_language.h index 829f01fbcc6..c22890e30a0 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -338,7 +338,7 @@ public: Ref icon; Variant default_value; Vector> matches; - Vector> last_matches; + Vector> last_matches = { { -1, -1 } }; // This value correspond to an impossible match int location = LOCATION_OTHER; CodeCompletionOption() {} diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index efbc067d200..c453d862642 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -3326,8 +3326,6 @@ CodeEdit::~CodeEdit() { // Return true if l should come before r bool CodeCompletionOptionCompare::operator()(const ScriptLanguage::CodeCompletionOption &l, const ScriptLanguage::CodeCompletionOption &r) const { - // Check if we are not completing an empty string in this case there is no reason to get matches characteristics. - TypedArray lcharac = l.get_option_cached_characteristics(); TypedArray rcharac = r.get_option_cached_characteristics(); @@ -3344,5 +3342,5 @@ bool CodeCompletionOptionCompare::operator()(const ScriptLanguage::CodeCompletio return l.matches[i].second > r.matches[i].second; } } - return l.display < r.display; + return l.display.naturalnocasecmp_to(r.display) < 0; }