Skip to content

Commit 1f0f355

Browse files
committed
Merge pull request #109448 from kitbdev/script-drop-onready-add-empty-line
Add new line when dropping onready on empty line
2 parents 1ee48c5 + 2bc9bf5 commit 1f0f355

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

editor/script/script_text_editor.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,7 +2290,21 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
22902290
parts.append(_quote_drop_data(path));
22912291
}
22922292
}
2293-
text_to_drop = String(is_empty_line ? "\n" : ", ").join(parts);
2293+
String join_string;
2294+
if (is_empty_line) {
2295+
int indent_level = te->get_indent_level(drop_at_line);
2296+
if (te->is_indent_using_spaces()) {
2297+
join_string = "\n" + String(" ").repeat(indent_level);
2298+
} else {
2299+
join_string = "\n" + String("\t").repeat(indent_level / te->get_tab_size());
2300+
}
2301+
} else {
2302+
join_string = ", ";
2303+
}
2304+
text_to_drop = join_string.join(parts);
2305+
if (is_empty_line) {
2306+
text_to_drop += join_string;
2307+
}
22942308
}
22952309

22962310
if (type == "nodes") {
@@ -2351,7 +2365,7 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data
23512365
}
23522366
}
23532367

2354-
if (!is_empty_line && drop_at_column == 0) {
2368+
if (is_empty_line || drop_at_column == 0) {
23552369
text_to_drop += "\n";
23562370
}
23572371
} else {

0 commit comments

Comments
 (0)