[escher] TextField: make the handleEventWithText behaviour consistent:

when a text cannot be inserted because it overflows the buffer, don't
add anything

insertTextAtLocation already behaves like this but handleEventWithText
used to cap the inserted text which sometimes leads to a different
behaviour - it would insert a truncated text
This commit is contained in:
Émilie Feral
2020-02-03 11:02:34 +01:00
committed by Léa Saviot
parent 0c55ea4531
commit 0ffcf34eb7

View File

@@ -492,7 +492,13 @@ bool TextField::handleEventWithText(const char * eventText, bool indentation, bo
char buffer[bufferSize];
{
CodePoint c[] = {UCodePointEmpty, '\n'};
UTF8Helper::CopyAndRemoveCodePoints(buffer, bufferSize, eventText, c, 2);
bool complete = UTF8Helper::CopyAndRemoveCodePoints(buffer, bufferSize, eventText, c, 2);
/* If the text is too long to be stored in buffer, we do not insert any
* text. This behaviour is consistent with 'insertTextAtLocation'
* behaviour. */
if (!complete) {
return false;
}
}
// Replace System parentheses (used to keep layout tree structure) by normal parentheses
Poincare::SerializationHelper::ReplaceSystemParenthesesByUserParentheses(buffer);