Fixed firing of incorrect values to document changes rpl::event_stream.

This commit is contained in:
23rd 2019-10-25 02:34:34 +03:00
parent ee44c5b89e
commit ba12ebc67a
2 changed files with 10 additions and 1 deletions

View file

@ -2085,6 +2085,9 @@ void InputField::processFormatting(int insertPosition, int insertEnd) {
action.intervalStart = fragmentPosition + (ch - textStart);
action.intervalEnd = action.intervalStart + emojiLength;
}
if (emojiLength > 1) {
_emojiSurrogateAmount += emojiLength - 1;
}
break;
}
@ -2220,7 +2223,9 @@ void InputField::onDocumentContentsChange(
_correcting = false;
QTextCursor(document->docHandle(), 0).endEditBlock();
handleContentsChanged();
_documentContentsChanges.fire({position, charsRemoved, charsAdded});
const auto added = charsAdded - _emojiSurrogateAmount;
_documentContentsChanges.fire({position, charsRemoved, added});
_emojiSurrogateAmount = 0;
});
chopByMaxLength(insertPosition, insertLength);

View file

@ -482,6 +482,10 @@ private:
int _realInsertPosition = -1;
int _realCharsAdded = 0;
// Calculate the amount of emoji extra chars
// before _documentContentsChanges fire.
int _emojiSurrogateAmount = 0;
std::unique_ptr<TagMimeProcessor> _tagMimeProcessor;
SubmitSettings _submitSettings = SubmitSettings::Enter;