From 07d360fbf6290abd2b70026778c9b82943b39a56 Mon Sep 17 00:00:00 2001 From: Infiland <88491175+Infiland@users.noreply.github.com> Date: Thu, 2 Apr 2026 23:18:44 +0200 Subject: [PATCH] Fix script editor errors shown out of order When warnings are treated as errors in GDScript, they are appended to the error list via `push_error()` without regard for line ordering. This causes them to appear after all other errors in the editor panel, regardless of their actual line numbers. Sort errors by line number (with column as tiebreaker) in `_validate_script()` before display. This ensures the error panel and the first-error indicator both reflect the correct source order. The fix is language-agnostic, benefiting all script languages. --- editor/script/script_text_editor.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/editor/script/script_text_editor.cpp b/editor/script/script_text_editor.cpp index 8091b9b043..bca7adb364 100644 --- a/editor/script/script_text_editor.cpp +++ b/editor/script/script_text_editor.cpp @@ -838,6 +838,15 @@ Ref ScriptTextEditor::get_theme_icon() { return Ref(); } +struct ScriptErrorLineComparator { + bool operator()(const ScriptLanguage::ScriptError &p_a, const ScriptLanguage::ScriptError &p_b) const { + if (p_a.line != p_b.line) { + return p_a.line < p_b.line; + } + return p_a.column < p_b.column; + } +}; + void ScriptTextEditor::_validate_script() { CodeEdit *te = code_editor->get_text_editor(); @@ -851,6 +860,8 @@ void ScriptTextEditor::_validate_script() { Ref