Browse Source

Include quotes conditionally for dropped paths

(cherry picked from commit 995bcd6218c6a33b89fa2456a9cf8903ecfe5c66)
kobewi 3 years ago
parent
commit
07953346fa
1 changed files with 9 additions and 2 deletions
  1. 9 2
      editor/plugins/script_text_editor.cpp

+ 9 - 2
editor/plugins/script_text_editor.cpp

@@ -1582,7 +1582,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
 		} else {
 			for (int i = 0; i < nodes.size(); i++) {
 				if (i > 0) {
-					text_to_drop += ",";
+					text_to_drop += ", ";
 				}
 
 				NodePath np = nodes[i];
@@ -1592,7 +1592,14 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
 				}
 
 				String path = sn->get_path_to(node);
-				text_to_drop += path.c_escape().quote(quote_style);
+				Vector<String> segments = path.split("/");
+				for (int j = 0; j < segments.size(); j++) {
+					if (!segments[j].is_valid_identifier()) {
+						path = path.c_escape().quote(quote_style);
+						break;
+					}
+				}
+				text_to_drop += "$" + path;
 			}
 		}