Browse Source

fix calculating length remaining till hitting limit (#6786)

pull/6788/head
qndel 2 years ago committed by GitHub
parent
commit
4fa97dd6de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      Source/DiabloUI/text_input.hpp

6
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

Loading…
Cancel
Save