Allow collapsed compositing range (flutter/engine#27869)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user