From 0df5684adf3117f4018e4b34868f6c41ee7125e3 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 19 Nov 2025 22:54:59 +0300 Subject: [PATCH] fix: undo/redo also available when textbox is not editable --- src/graphics/ui/elements/TextBox.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/graphics/ui/elements/TextBox.cpp b/src/graphics/ui/elements/TextBox.cpp index 8f24217d..5e7ab370 100644 --- a/src/graphics/ui/elements/TextBox.cpp +++ b/src/graphics/ui/elements/TextBox.cpp @@ -484,7 +484,7 @@ void TextBox::erase(size_t start, size_t length) { setCaret(caret - length); } auto left = input.substr(0, start); - auto right = input.substr(end); + auto right = end >= input.length() ? L"" : input.substr(end); input = left + right; } @@ -1034,11 +1034,11 @@ void TextBox::keyPressed(Keycode key) { resetSelection(); } } - if (key == Keycode::Z) { + if (editable && key == Keycode::Z) { historian->undo(); refreshSyntax(); } - if (key == Keycode::Y) { + if (editable && key == Keycode::Y) { historian->redo(); refreshSyntax(); }