diff --git a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java index d5236c4ff7..80718cf363 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java @@ -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) diff --git a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java index 2c928d8d6d..1b41992b6c 100644 --- a/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java +++ b/engine/src/flutter/shell/platform/android/test/io/flutter/plugin/editing/TextInputPluginTest.java @@ -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