Support single quote when dropping files to script

(cherry picked from commit 5e593dda9b)
This commit is contained in:
kobewi 2021-07-03 01:41:39 +02:00 committed by Rémi Verschelde
parent d453b59cba
commit 245b9400ea
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -1504,6 +1504,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
} }
if (d.has("type") && (String(d["type"]) == "files" || String(d["type"]) == "files_and_dirs")) { if (d.has("type") && (String(d["type"]) == "files" || String(d["type"]) == "files_and_dirs")) {
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
Array files = d["files"]; Array files = d["files"];
String text_to_drop; String text_to_drop;
@ -1514,9 +1515,9 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
} }
if (preload) { if (preload) {
text_to_drop += "preload(\"" + String(files[i]).c_escape() + "\")"; text_to_drop += "preload(" + String(files[i]).c_escape().quote(quote_style) + ")";
} else { } else {
text_to_drop += "\"" + String(files[i]).c_escape() + "\""; text_to_drop += String(files[i]).c_escape().quote(quote_style);
} }
} }