Merge pull request #1370 from abarth/commit_on_release

Keyboard service doesn't commit the last edit when it's dismissed
This commit is contained in:
Adam Barth 2016-01-25 13:48:30 -08:00
commit a46fb2c4db
2 changed files with 7 additions and 4 deletions

View File

@ -109,6 +109,7 @@ class _InputState extends State<Input> {
_editableString.selection.end);
} else if (!focused && _keyboardHandle.attached) {
_keyboardHandle.release();
_editableString.composing = TextRange.empty;
}
}

View File

@ -26,10 +26,12 @@ class TextRange {
end = position;
/// A text range that contains nothing and is not in the text.
const TextRange.empty()
const TextRange._empty()
: start = -1,
end = -1;
static const TextRange empty = const TextRange._empty();
/// The index of the first character in the range.
final int start;
@ -56,7 +58,7 @@ class EditableString implements KeyboardClient {
String text;
// The range of text that is still being composed.
TextRange composing = const TextRange.empty();
TextRange composing = TextRange.empty;
/// The range of text that is currently selected.
TextRange selection;
@ -124,7 +126,7 @@ class EditableString implements KeyboardClient {
// TODO(abarth): Why is |newCursorPosition| always 1?
TextRange committedRange = _replaceOrAppend(composing, text);
selection = new TextRange.collapsed(committedRange.end);
composing = const TextRange.empty();
composing = TextRange.empty;
onUpdated();
}
@ -161,7 +163,7 @@ class EditableString implements KeyboardClient {
}
void submit(SubmitAction action) {
composing = const TextRange.empty();
composing = TextRange.empty;
onSubmitted();
}
}