Merge pull request #76145 from manueldun/usability-auto-indent

Fix auto-indentation in typed arrays, comments, and after colon
This commit is contained in:
Rémi Verschelde 2023-04-24 16:45:35 +02:00
commit c0ee2b4968
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 12 additions and 1 deletions

View File

@ -1071,7 +1071,7 @@ void CodeEdit::_new_line(bool p_split_current_line, bool p_above) {
for (; line_col < cc; line_col++) {
char32_t c = line[line_col];
if (auto_indent_prefixes.has(c)) {
if (auto_indent_prefixes.has(c) && is_in_comment(cl, line_col) == -1) {
should_indent = true;
indent_char = c;
continue;

View File

@ -2300,6 +2300,17 @@ TEST_CASE("[SceneTree][CodeEdit] indent") {
SEND_GUI_ACTION("ui_text_newline_blank");
CHECK(code_edit->get_line(0) == "test{}");
CHECK(code_edit->get_line(1) == "");
/* If there is something after a colon
and there is a colon in the comment it
should not indent. */
code_edit->add_comment_delimiter("#", "");
code_edit->set_text("");
code_edit->insert_text_at_caret("test:test#:");
SEND_GUI_ACTION("ui_text_newline");
CHECK(code_edit->get_line(0) == "test:test#:");
CHECK(code_edit->get_line(1) == "");
code_edit->remove_comment_delimiter("#");
}
}