Skip to content

Commit 2668f90

Browse files
authored
Composing text shouldn't be part of undo/redo (#108765)
Fixes undo/redo behavior when using a composing keyboard, especially on desktop.
1 parent 780ceb5 commit 2668f90

File tree

2 files changed

+607
-0
lines changed

2 files changed

+607
-0
lines changed

packages/flutter/lib/src/widgets/editable_text.dart

+18
Original file line numberDiff line numberDiff line change
@@ -4712,6 +4712,24 @@ class _TextEditingHistoryState extends State<_TextEditingHistory> {
47124712
return;
47134713
}
47144714

4715+
switch (defaultTargetPlatform) {
4716+
case TargetPlatform.iOS:
4717+
case TargetPlatform.macOS:
4718+
case TargetPlatform.fuchsia:
4719+
case TargetPlatform.linux:
4720+
case TargetPlatform.windows:
4721+
// Composing text is not counted in history coalescing.
4722+
if (!widget.controller.value.composing.isCollapsed) {
4723+
return;
4724+
}
4725+
break;
4726+
case TargetPlatform.android:
4727+
// Gboard on Android puts non-CJK words in composing regions. Coalesce
4728+
// composing text in order to allow the saving of partial words in that
4729+
// case.
4730+
break;
4731+
}
4732+
47154733
_throttleTimer = _throttledPush(widget.controller.value);
47164734
}
47174735

0 commit comments

Comments
 (0)