From 4fa97dd6dee288594c4acdff38db2892af211d5a Mon Sep 17 00:00:00 2001 From: qndel Date: Mon, 6 Nov 2023 20:09:01 +0100 Subject: [PATCH] fix calculating length remaining till hitting limit (#6786) --- Source/DiabloUI/text_input.hpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/DiabloUI/text_input.hpp b/Source/DiabloUI/text_input.hpp index b35a181e4..3b5a74384 100644 --- a/Source/DiabloUI/text_input.hpp +++ b/Source/DiabloUI/text_input.hpp @@ -113,11 +113,7 @@ class TextInputState { */ [[nodiscard]] std::string_view truncateForInsertion(std::string_view text) const { - const size_t newLength = len_ + text.size(); - if (newLength > maxLength_) { - return TruncateUtf8(text, newLength - maxLength_); - } - return text; + return TruncateUtf8(text, maxLength_ - len_); } char *buf_; // unowned