summaryrefslogtreecommitdiffstats
path: root/editor/code_editor.cpp
diff options
context:
space:
mode:
authorDanil Alexeev <danil@alexeev.xyz>2024-04-21 22:14:18 +0300
committerDanil Alexeev <danil@alexeev.xyz>2024-07-17 18:20:50 +0300
commit063a362755dc64c4e9e58fdb579a6151e21a399b (patch)
tree0338e28a54faed989bf28ef4e4ab3d596eff1c0a /editor/code_editor.cpp
parent97b8ad1af0f2b4a216f6f1263bef4fbc69e56c7b (diff)
downloadredot-engine-063a362755dc64c4e9e58fdb579a6151e21a399b.tar.gz
Editor: Consider tabs when calculating column for jump to error
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r--editor/code_editor.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index a9d37a6a99..d24b1edd70 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1431,12 +1431,21 @@ Point2i CodeTextEditor::get_error_pos() const {
void CodeTextEditor::goto_error() {
if (!error->get_text().is_empty()) {
+ int corrected_column = error_column;
+
+ const String line_text = text_editor->get_line(error_line);
+ const int indent_size = text_editor->get_indent_size();
+ if (indent_size > 1) {
+ const int tab_count = line_text.length() - line_text.lstrip("\t").length();
+ corrected_column -= tab_count * (indent_size - 1);
+ }
+
if (text_editor->get_line_count() != error_line) {
text_editor->unfold_line(error_line);
}
text_editor->remove_secondary_carets();
text_editor->set_caret_line(error_line);
- text_editor->set_caret_column(error_column);
+ text_editor->set_caret_column(corrected_column);
text_editor->center_viewport_to_caret();
}
}