Fixed firing of incorrect values to document changes rpl::event_stream.
This commit is contained in:
parent
ee44c5b89e
commit
ba12ebc67a
2 changed files with 10 additions and 1 deletions
|
|
@ -2085,6 +2085,9 @@ void InputField::processFormatting(int insertPosition, int insertEnd) {
|
||||||
action.intervalStart = fragmentPosition + (ch - textStart);
|
action.intervalStart = fragmentPosition + (ch - textStart);
|
||||||
action.intervalEnd = action.intervalStart + emojiLength;
|
action.intervalEnd = action.intervalStart + emojiLength;
|
||||||
}
|
}
|
||||||
|
if (emojiLength > 1) {
|
||||||
|
_emojiSurrogateAmount += emojiLength - 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2220,7 +2223,9 @@ void InputField::onDocumentContentsChange(
|
||||||
_correcting = false;
|
_correcting = false;
|
||||||
QTextCursor(document->docHandle(), 0).endEditBlock();
|
QTextCursor(document->docHandle(), 0).endEditBlock();
|
||||||
handleContentsChanged();
|
handleContentsChanged();
|
||||||
_documentContentsChanges.fire({position, charsRemoved, charsAdded});
|
const auto added = charsAdded - _emojiSurrogateAmount;
|
||||||
|
_documentContentsChanges.fire({position, charsRemoved, added});
|
||||||
|
_emojiSurrogateAmount = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
chopByMaxLength(insertPosition, insertLength);
|
chopByMaxLength(insertPosition, insertLength);
|
||||||
|
|
|
||||||
|
|
@ -482,6 +482,10 @@ private:
|
||||||
int _realInsertPosition = -1;
|
int _realInsertPosition = -1;
|
||||||
int _realCharsAdded = 0;
|
int _realCharsAdded = 0;
|
||||||
|
|
||||||
|
// Calculate the amount of emoji extra chars
|
||||||
|
// before _documentContentsChanges fire.
|
||||||
|
int _emojiSurrogateAmount = 0;
|
||||||
|
|
||||||
std::unique_ptr<TagMimeProcessor> _tagMimeProcessor;
|
std::unique_ptr<TagMimeProcessor> _tagMimeProcessor;
|
||||||
|
|
||||||
SubmitSettings _submitSettings = SubmitSettings::Enter;
|
SubmitSettings _submitSettings = SubmitSettings::Enter;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue