From 686f8f43c373ed9a21a9b6586b10a1541e52f38a Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 27 Dec 2023 17:29:27 +0100 Subject: [PATCH] fix: Pattern editor error tooltip becoming way too large in some cases --- .../source/content/views/view_pattern_editor.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index cd8b221d1..dccacb181 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -749,8 +749,22 @@ namespace hex::plugin::builtin { if (!m_lastEvaluationProcessed) { if (!m_lastEvaluationResult) { if (m_lastEvaluationError->has_value()) { + const auto message = [this]{ + auto message = (*m_lastEvaluationError)->message; + auto lines = wolv::util::splitString(message, "\n"); + + std::ranges::transform(lines, lines.begin(), [](auto line) { + if (line.size() >= 128) + line = wolv::util::trim(line); + + return hex::limitStringLength(line, 128); + }); + + return wolv::util::combineStrings(lines, "\n"); + }(); + TextEditor::ErrorMarkers errorMarkers = { - { (*m_lastEvaluationError)->line, (*m_lastEvaluationError)->message } + { (*m_lastEvaluationError)->line, message } }; m_textEditor.SetErrorMarkers(errorMarkers); }