performAction method
Requests that this client perform the given action.
Implementation
@override
void performAction(TextInputAction action) {
if (_document == null) return;
switch (action) {
case TextInputAction.newline:
// If the newline was already handled via delta (iOS virtual
// keyboard often sends both a delta and a performAction),
// skip the second enter to avoid double-splitting.
if (_justHandledEnter) {
_justHandledEnter = false;
break;
}
// Start grace period BEFORE the structural change so any platform
// echo that arrives during the split is ignored.
_structuralChangeInProgress = true;
_structuralChangeTimer?.cancel();
// Commit any pending preedit first, then handle enter.
commitIfComposing();
_document!.saveState(description: 'Enter', forceNewAction: true);
executeHandleEnter(_document!);
// Sync the IME buffer with the NEW fragment text so the platform
// computes subsequent deltas against the correct content. On iOS
// this also injects the zero-width placeholder when the cursor is
// at offset 0, preventing Backspace from being swallowed.
_lastSyncedFragmentId = _document!.cursor.focusId.isNotEmpty
? _document!.cursor.focusId
: _document!.cursor.anchorId;
syncImeBufferToFragment();
_structuralChangeTimer = Timer(_structuralChangeGracePeriod, () {
_structuralChangeInProgress = false;
});
break;
case TextInputAction.go:
case TextInputAction.send:
case TextInputAction.done:
commitIfComposing();
break;
default:
break;
}
}