entering a character with a selection deletes the selection (flutter/engine#6113)

This commit is contained in:
jslavitz
2018-08-30 10:29:04 -07:00
committed by GitHub
parent 9c3f354418
commit 6638f518c6

View File

@@ -158,6 +158,9 @@ class InputConnectionAdaptor extends BaseInputConnection {
int character = event.getUnicodeChar();
if (character != 0) {
int selStart = Math.max(0, Selection.getSelectionStart(mEditable));
int selEnd = Selection.getSelectionEnd(mEditable);
if (selEnd != selStart)
mEditable.delete(selStart, selEnd);
mEditable.insert(selStart, String.valueOf((char) character));
setSelection(selStart + 1, selStart + 1);
updateEditingState();