summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-02-08 10:54:12 +0100
committerRémi Verschelde <rverschelde@gmail.com>2024-02-08 10:54:12 +0100
commit50491db04845644d72e5ffd942e6f6dd2c3c34e6 (patch)
treef0d3c5dcf5080a82b0593aceaa0ee84f291b7f4f
parentaf645c49772e1a3eac86b0a6d3b272635ddaff3d (diff)
parent1238b60b22194072dddf7b31cce007426837b35c (diff)
downloadredot-engine-50491db04845644d72e5ffd942e6f6dd2c3c34e6.tar.gz
Merge pull request #88071 from Calinou/gdscript-nodepath-autocomplete-fix-identifiers
Fix NodePath autocompletion to ensure paths are quoted when required
-rw-r--r--modules/gdscript/gdscript_editor.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index d45acbcae8..78f9c0846f 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -3328,9 +3328,17 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
opt = opt.substr(1);
}
- // The path needs quotes if it's not a valid identifier (with an exception
- // for "/" as path separator, which also doesn't require quotes).
- if (!opt.replace("/", "_").is_valid_identifier()) {
+ // The path needs quotes if at least one of its components (excluding `/` separations)
+ // is not a valid identifier.
+ bool path_needs_quote = false;
+ for (const String &part : opt.split("/")) {
+ if (!part.is_valid_identifier()) {
+ path_needs_quote = true;
+ break;
+ }
+ }
+
+ if (path_needs_quote) {
// Ignore quote_style and just use double quotes for paths with apostrophes.
// Double quotes don't need to be checked because they're not valid in node and property names.
opt = opt.quote(opt.contains("'") ? "\"" : quote_style); // Handle user preference.