From 25253115389ed90c60972217ae9f141886490c19 Mon Sep 17 00:00:00 2001 From: aXu-AP <1621768+aXu-AP@users.noreply.github.com> Date: Fri, 6 Sep 2024 23:41:32 +0300 Subject: [PATCH] Remove unneeded quotes from autocomplete % nodes Removes unnecessary quotes for suggestions like $"%MyNode". --- modules/gdscript/gdscript_editor.cpp | 4 ++-- .../completion/get_node/literal_scene/dollar_unique.cfg | 9 +++++++++ .../completion/get_node/literal_scene/dollar_unique.gd | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 modules/gdscript/tests/scripts/completion/get_node/literal_scene/dollar_unique.cfg create mode 100644 modules/gdscript/tests/scripts/completion/get_node/literal_scene/dollar_unique.gd diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index db7bef2f0796..b1c73ab8d164 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -3482,10 +3482,10 @@ ::Error GDScriptLanguage::complete_code(const String &p_code, const String &p_pa opt = opt.substr(1); } - // The path needs quotes if at least one of its components (excluding `/` separations) + // The path needs quotes if at least one of its components (excluding `%` prefix and `/` separations) // is not a valid identifier. bool path_needs_quote = false; - for (const String &part : opt.split("/")) { + for (const String &part : opt.trim_prefix("%").split("/")) { if (!part.is_valid_ascii_identifier()) { path_needs_quote = true; break; diff --git a/modules/gdscript/tests/scripts/completion/get_node/literal_scene/dollar_unique.cfg b/modules/gdscript/tests/scripts/completion/get_node/literal_scene/dollar_unique.cfg new file mode 100644 index 000000000000..36c150f6e36c --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/get_node/literal_scene/dollar_unique.cfg @@ -0,0 +1,9 @@ +[input] +scene="res://completion/get_node/get_node.tscn" +[output] +include=[ + {"display": "%UniqueA"}, +] +exclude=[ + {"display": "\"%UniqueA\""}, +] diff --git a/modules/gdscript/tests/scripts/completion/get_node/literal_scene/dollar_unique.gd b/modules/gdscript/tests/scripts/completion/get_node/literal_scene/dollar_unique.gd new file mode 100644 index 000000000000..def050e938a7 --- /dev/null +++ b/modules/gdscript/tests/scripts/completion/get_node/literal_scene/dollar_unique.gd @@ -0,0 +1,5 @@ +extends Node + +func a(): + $➡ + pass