Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

GDScript Editor: Fix diagnostic underlines not displaying when range extends past EOF

Malcolm Andersona87a3eba055d
diff --git a/editor/script/script_text_editor.cpp b/editor/script/script_text_editor.cpp
index 4bf3aa24d8b..9579bbf9455 100644
--- a/editor/script/script_text_editor.cpp
+++ b/editor/script/script_text_editor.cpp
@@ -753,6 +753,13 @@ void ScriptTextEditor::_update_background_color() {
int warning_start_column = warning.start_column - 1;
int warning_end_line = CLAMP(warning.end_line - 1, 0, te->get_line_count() - 1);
int warning_end_column = warning.end_column - 1;
+
+ // If this warning's range extends to a non-existent line, then the
+ // best we can do is have it go to the end of this current line.
+ if (warning.end_line - 1 >= te->get_line_count() - 1) {
+ warning_end_column = te->get_line(warning_end_line).length();
+ }
+
int folded_line_header = te->get_folded_line_header(warning_start_line);
if (warning_underline_color.a != 0.0) {
@@ -780,6 +787,13 @@ void ScriptTextEditor::_update_background_color() {
int error_start_column = error.start_column - 1;
int error_end_line = CLAMP(error.end_line - 1, 0, te->get_line_count() - 1);
int error_end_column = error.end_column - 1;
+
+ // If this error's range extends to a non-existent line, then the
+ // best we can do is have it go to the end of this current line.
+ if (error.end_line - 1 >= te->get_line_count() - 1) {
+ error_end_column = te->get_line(error_end_line).length();
+ }
+
int folded_line_header = te->get_folded_line_header(error_start_line);
if (error_underline_color.a != 0.0) {