From 19632eaf5006ed147e0922523da268f62b528033 Mon Sep 17 00:00:00 2001 From: ajreckof <66184050+ajreckof@users.noreply.github.com> Date: Mon, 4 Sep 2023 17:08:14 +0200 Subject: [PATCH] Change precedence in rules to make location after proper casing. --- core/object/script_language.cpp | 2 +- tests/scene/test_code_edit.h | 38 ++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index a8b0e426aea3..0de03662a0b4 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -482,7 +482,6 @@ TypedArray ScriptLanguage::CodeCompletionOption::get_option_characteristics } charac.push_back(matches.size()); charac.push_back((matches[0].first == 0) ? 0 : 1); - charac.push_back(location); const char32_t *target_char = &p_base[0]; int bad_case = 0; for (const Pair &match_segment : matches) { @@ -494,6 +493,7 @@ TypedArray ScriptLanguage::CodeCompletionOption::get_option_characteristics } } charac.push_back(bad_case); + charac.push_back(location); charac.push_back(matches[0].first); last_matches = matches; return charac; diff --git a/tests/scene/test_code_edit.h b/tests/scene/test_code_edit.h index d6858fbcb414..72421c9cc90b 100644 --- a/tests/scene/test_code_edit.h +++ b/tests/scene/test_code_edit.h @@ -3446,7 +3446,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { } SUBCASE("[CodeEdit] autocomplete suggestion order") { - /* Favorize less fragmented suggestion. */ + /* Prefer less fragmented suggestion. */ code_edit->clear(); code_edit->insert_text_at_caret("te"); code_edit->set_caret_column(2); @@ -3456,7 +3456,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { code_edit->confirm_code_completion(); CHECK(code_edit->get_line(0) == "test"); - /* Favorize suggestion starting from the string to complete (matching start). */ + /* Prefer suggestion starting with the string to complete (matching start). */ code_edit->clear(); code_edit->insert_text_at_caret("te"); code_edit->set_caret_column(2); @@ -3466,7 +3466,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { code_edit->confirm_code_completion(); CHECK(code_edit->get_line(0) == "test"); - /* Favorize less fragment to matching start. */ + /* Prefer less fragment over matching start. */ code_edit->clear(); code_edit->insert_text_at_caret("te"); code_edit->set_caret_column(2); @@ -3476,37 +3476,37 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { code_edit->confirm_code_completion(); CHECK(code_edit->get_line(0) == "stest"); - /* Favorize closer location. */ + /* Prefer good capitalization. */ code_edit->clear(); code_edit->insert_text_at_caret("te"); code_edit->set_caret_column(2); code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "test", "test"); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "test_bis", "test_bis", Color(1, 1, 1), Ref(), Variant::NIL, CodeEdit::LOCATION_LOCAL); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "Test", "Test"); code_edit->update_code_completion_options(); code_edit->confirm_code_completion(); - CHECK(code_edit->get_line(0) == "test_bis"); + CHECK(code_edit->get_line(0) == "test"); - /* Favorize matching start to location. */ + /* Prefer matching start over good capitalization. */ code_edit->clear(); code_edit->insert_text_at_caret("te"); code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "test", "test"); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "stest_bis", "test_bis", Color(1, 1, 1), Ref(), Variant::NIL, CodeEdit::LOCATION_LOCAL); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "Test", "Test"); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "stest_bis", "test_bis"); code_edit->update_code_completion_options(); code_edit->confirm_code_completion(); - CHECK(code_edit->get_line(0) == "test"); + CHECK(code_edit->get_line(0) == "Test"); - /* Favorize good capitalization. */ + /* Prefer closer location. */ code_edit->clear(); code_edit->insert_text_at_caret("te"); code_edit->set_caret_column(2); code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "test", "test"); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "Test", "Test"); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "test_bis", "test_bis", Color(1, 1, 1), Ref(), Variant::NIL, CodeEdit::LOCATION_LOCAL); code_edit->update_code_completion_options(); code_edit->confirm_code_completion(); - CHECK(code_edit->get_line(0) == "test"); + CHECK(code_edit->get_line(0) == "test_bis"); - /* Favorize location to good capitalization. */ + /* Prefer good capitalization over location. */ code_edit->clear(); code_edit->insert_text_at_caret("te"); code_edit->set_caret_column(2); @@ -3514,9 +3514,9 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "Test", "Test", Color(1, 1, 1), Ref(), Variant::NIL, CodeEdit::LOCATION_LOCAL); code_edit->update_code_completion_options(); code_edit->confirm_code_completion(); - CHECK(code_edit->get_line(0) == "Test"); + CHECK(code_edit->get_line(0) == "test"); - /* Favorize string to complete being closest to the start of the suggestion (closest to start). */ + /* Prefer the start of the string to complete being closest to the start of the suggestion (closest to start). */ code_edit->clear(); code_edit->insert_text_at_caret("te"); code_edit->set_caret_column(2); @@ -3526,12 +3526,12 @@ TEST_CASE("[SceneTree][CodeEdit] completion") { code_edit->confirm_code_completion(); CHECK(code_edit->get_line(0) == "stest"); - /* Favorize good capitalization to closest to start. */ + /* Prefer location over closest to start. */ code_edit->clear(); code_edit->insert_text_at_caret("te"); code_edit->set_caret_column(2); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "sTest", "stest"); - code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "sstest", "sstest"); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "stest", "stest"); + code_edit->add_code_completion_option(CodeEdit::CodeCompletionKind::KIND_VARIABLE, "sstest", "sstest", Color(1, 1, 1), Ref(), Variant::NIL, CodeEdit::LOCATION_LOCAL); code_edit->update_code_completion_options(); code_edit->confirm_code_completion(); CHECK(code_edit->get_line(0) == "sstest");