Tree: Add per-cell autowrap_trim_flags to TreeItem

The Debugger Errors tab previously displayed ASCII art diagnostic output
(like Rust/Elm-style error messages) incorrectly because the Tree widget
hardcoded space trimming flags, causing leading spaces on wrapped lines
to be trimmed and breaking alignment.

This adds a per-cell `autowrap_trim_flags` property to TreeItem, following
the pattern used by Label and RichTextLabel. The debugger errors tab now
disables trim flags and uses the same monospace font as the Output panel,
ensuring proper alignment of structured error messages.
This commit is contained in:
Philippe Vaillancourt
2025-12-24 15:28:15 -05:00
parent 63227bbc8a
commit e046830c50
4 changed files with 51 additions and 1 deletions

View File

@@ -678,6 +678,7 @@ void ScriptEditorDebugger::_msg_error(uint64_t p_thread_id, const Array &p_data)
error_title += oe.error_descr.is_empty() ? oe.error : oe.error_descr;
error->set_text(1, error_title);
error->set_autowrap_mode(1, TextServer::AUTOWRAP_WORD_SMART);
error->set_autowrap_trim_flags(1, 0);
tooltip += " " + error_title + "\n";
// Find the language of the error's source file.
@@ -1117,6 +1118,13 @@ void ScriptEditorDebugger::_notification(int p_what) {
reason->add_theme_color_override(SNAME("default_color"), get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
reason->add_theme_style_override(SNAME("normal"), get_theme_stylebox(SNAME("normal"), SNAME("Label"))); // Empty stylebox.
const Ref<Font> source_font = get_theme_font(SNAME("output_source"), EditorStringName(EditorFonts));
if (source_font.is_valid()) {
error_tree->add_theme_font_override("font", source_font);
}
const int font_size = get_theme_font_size(SNAME("output_source_size"), EditorStringName(EditorFonts));
error_tree->add_theme_font_size_override("font_size", font_size);
TreeItem *error_root = error_tree->get_root();
if (error_root) {
TreeItem *error = error_root->get_first_child();