fix issue 32212 Text field keyboard selection crashes (#32256)
This commit is contained in:
parent
c27d10bf46
commit
21efdff8a5
@ -428,7 +428,7 @@ class RenderEditable extends RenderBox {
|
||||
int _handleHorizontalArrows(bool rightArrow, bool leftArrow, bool shift, int newOffset) {
|
||||
// Set the new offset to be +/- 1 depending on which arrow is pressed
|
||||
// If shift is down, we also want to update the previous cursor location
|
||||
if (rightArrow && _extentOffset < text.text.length) {
|
||||
if (rightArrow && _extentOffset < text.toPlainText().length) {
|
||||
newOffset += 1;
|
||||
if (shift)
|
||||
_previousCursorLocation += 1;
|
||||
|
@ -2973,6 +2973,23 @@ void main() {
|
||||
expect(controller.selection.extentOffset - controller.selection.baseOffset, 1);
|
||||
});
|
||||
|
||||
testWidgets('Shift test 2', (WidgetTester tester) async {
|
||||
await setupWidget(tester);
|
||||
|
||||
const String testValue = 'abcdefghi';
|
||||
await tester.showKeyboard(find.byType(TextField));
|
||||
tester.testTextInput.updateEditingValue(const TextEditingValue(
|
||||
text: testValue,
|
||||
selection: TextSelection.collapsed(offset: 3),
|
||||
composing: TextRange(start: 0, end: testValue.length)
|
||||
));
|
||||
await tester.pump();
|
||||
|
||||
sendKeyEventWithCode(22, true, true, false);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.selection.extentOffset - controller.selection.baseOffset, 1);
|
||||
});
|
||||
|
||||
testWidgets('Control Shift test', (WidgetTester tester) async {
|
||||
await setupWidget(tester);
|
||||
const String testValue = 'their big house';
|
||||
|
Loading…
x
Reference in New Issue
Block a user