@@ -1296,23 +1296,29 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
1296
1296
text_editor->end_complex_operation ();
1297
1297
}
1298
1298
1299
- void CodeTextEditor::goto_line (int p_line) {
1299
+ void CodeTextEditor::goto_line (int p_line, int p_column ) {
1300
1300
text_editor->remove_secondary_carets ();
1301
1301
text_editor->deselect ();
1302
- text_editor->unfold_line (p_line);
1303
- callable_mp ((TextEdit *)text_editor, &TextEdit::set_caret_line).call_deferred (p_line, true , true , 0 , 0 );
1302
+ text_editor->unfold_line (CLAMP (p_line, 0 , text_editor->get_line_count () - 1 ));
1303
+ text_editor->set_caret_line (p_line, false );
1304
+ text_editor->set_caret_column (p_column, false );
1305
+ // Defer in case the CodeEdit was just created and needs to be resized.
1306
+ callable_mp ((TextEdit *)text_editor, &TextEdit::adjust_viewport_to_caret).call_deferred (0 );
1304
1307
}
1305
1308
1306
1309
void CodeTextEditor::goto_line_selection (int p_line, int p_begin, int p_end) {
1307
1310
text_editor->remove_secondary_carets ();
1308
- text_editor->unfold_line (p_line);
1309
- callable_mp ((TextEdit *)text_editor, &TextEdit::set_caret_line).call_deferred (p_line, true , true , 0 , 0 );
1310
- callable_mp ((TextEdit *)text_editor, &TextEdit::set_caret_column).call_deferred (p_begin, true , 0 );
1311
+ text_editor->unfold_line (CLAMP (p_line, 0 , text_editor->get_line_count () - 1 ));
1311
1312
text_editor->select (p_line, p_begin, p_line, p_end);
1313
+ callable_mp ((TextEdit *)text_editor, &TextEdit::adjust_viewport_to_caret).call_deferred (0 );
1312
1314
}
1313
1315
1314
- void CodeTextEditor::goto_line_centered (int p_line) {
1315
- goto_line (p_line);
1316
+ void CodeTextEditor::goto_line_centered (int p_line, int p_column) {
1317
+ text_editor->remove_secondary_carets ();
1318
+ text_editor->deselect ();
1319
+ text_editor->unfold_line (CLAMP (p_line, 0 , text_editor->get_line_count () - 1 ));
1320
+ text_editor->set_caret_line (p_line, false );
1321
+ text_editor->set_caret_column (p_column, false );
1316
1322
callable_mp ((TextEdit *)text_editor, &TextEdit::center_viewport_to_caret).call_deferred (0 );
1317
1323
}
1318
1324
@@ -1440,13 +1446,7 @@ void CodeTextEditor::goto_error() {
1440
1446
corrected_column -= tab_count * (indent_size - 1 );
1441
1447
}
1442
1448
1443
- if (text_editor->get_line_count () != error_line) {
1444
- text_editor->unfold_line (error_line);
1445
- }
1446
- text_editor->remove_secondary_carets ();
1447
- text_editor->set_caret_line (error_line);
1448
- text_editor->set_caret_column (corrected_column);
1449
- text_editor->center_viewport_to_caret ();
1449
+ goto_line_centered (error_line, corrected_column);
1450
1450
}
1451
1451
}
1452
1452
0 commit comments