Allow collapsed compositing range (flutter/engine#27869)

This commit is contained in:
Emmanuel Garcia
2021-08-03 13:20:02 -07:00
committed by GitHub
parent 1af450987a
commit 09e80c18f1
2 changed files with 8 additions and 3 deletions

View File

@@ -722,7 +722,7 @@ public class TextInputChannel {
}
if ((composingStart != -1 || composingEnd != -1)
&& (composingStart < 0 || composingStart >= composingEnd)) {
&& (composingStart < 0 || composingStart > composingEnd)) {
throw new IndexOutOfBoundsException(
"invalid composing range: ("
+ String.valueOf(composingStart)

View File

@@ -429,8 +429,6 @@ public class TextInputPluginTest {
assertThrows(IndexOutOfBoundsException.class, () -> new TextEditState("Text", 0, 0, -1, -9));
assertThrows(IndexOutOfBoundsException.class, () -> new TextEditState("Text", 0, 0, -9, -9));
assertThrows(IndexOutOfBoundsException.class, () -> new TextEditState("Text", 0, 0, 2, 1));
// A collapsed composing range is invalid.
assertThrows(IndexOutOfBoundsException.class, () -> new TextEditState("Text", 0, 0, 1, 1));
// Valid values (does not throw):
// Nothing selected/composing:
@@ -448,6 +446,13 @@ public class TextInputPluginTest {
state = new TextEditState("REEEE", 4, 2, -1, -1);
assertEquals(4, state.selectionStart);
assertEquals(2, state.selectionEnd);
// A collapsed selection and composing range.
state = new TextEditState("text", 0, 0, 0, 0);
assertEquals("text", state.text);
assertEquals(0, state.selectionStart);
assertEquals(0, state.selectionEnd);
assertEquals(0, state.composingStart);
assertEquals(0, state.composingEnd);
}
@Test