Skip to content

DeltaTextInputClient has different behavior between macOS and Linux #113909

@LucasXu0

Description

@LucasXu0

Steps to Reproduce

Hi. I am developing an editor and need to use DeltaTextInputClient to receive the user input. Now I am doing some work to support the IME. But I found that it behaves differently for different platforms' IMEs.

  1. git clone https://github.com/LucasXu0/AppFlowy
  2. git checkout Ubuntu_IME
  3. cd frontend/app_flowy/packages/appflowy_editor/example
  4. Execute flutter run on the code sample

On Ubuntu 22.04, use the built-in Chinese input method.
5. input some text by IME.
6. The console will output

flutter: [DEBUG][input]: 2022-10-23 16:38:52.156089: (Instance of 'TextEditingDeltaReplacement')
flutter: [DEBUG][input]: 2022-10-23 16:38:52.156301: receive replacement: text = 为, composing = TextRange(start: 0, end: 1), selection = TextRange(start: 0, end: 1), old text =
flutter: [DEBUG][input]: 2022-10-23 16:38:53.135127: (Instance of 'TextEditingDeltaReplacement')
flutter: [DEBUG][input]: 2022-10-23 16:38:53.135340: receive replacement: text = 外文, composing = TextRange(start: 0, end: 2), selection = TextRange(start: 0, end: 2), old text = 为
flutter: [DEBUG][input]: 2022-10-23 16:38:54.168940: (Instance of 'TextEditingDeltaInsertion')
flutter: [DEBUG][input]: 2022-10-23 16:38:54.169132: receive insertion: text = 外文, composing = TextRange(start: -1, end: -1), selection = TextSelection.collapsed(offset: 4, affinity: TextAffinity.downstream, isDirectional: false)
flutter: [DEBUG][input]: 2022-10-23 16:38:54.174651: (Instance of 'TextEditingDeltaNonTextUpdate')

image

On macOS, use the built-in Chinese input method.
5. input some text by IME.
6. The console will output

flutter: [DEBUG][input]: 2022-10-23 17:59:17.606751: (Instance of 'TextEditingDeltaInsertion')
flutter: [DEBUG][input]: 2022-10-23 17:59:17.606847: receive insertion: text = w, composing = TextRange(start: 0, end: 1), selection = TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false)
flutter: [DEBUG][input]: 2022-10-23 17:59:17.630399: (Instance of 'TextEditingDeltaNonTextUpdate')
flutter: [DEBUG][input]: 2022-10-23 17:59:17.630577: receive non text update: composing = TextRange(start: 0, end: 1), selection = TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false)
flutter: [DEBUG][input]: 2022-10-23 17:59:18.074047: (Instance of 'TextEditingDeltaInsertion')
flutter: [DEBUG][input]: 2022-10-23 17:59:18.074145: receive insertion: text =  w, composing = TextRange(start: 0, end: 3), selection = TextSelection.collapsed(offset: 3, affinity: TextAffinity.downstream, isDirectional: false)
flutter: [DEBUG][input]: 2022-10-23 17:59:18.095028: (Instance of 'TextEditingDeltaNonTextUpdate')
flutter: [DEBUG][input]: 2022-10-23 17:59:18.095049: receive non text update: composing = TextRange(start: 0, end: 3), selection = TextSelection.collapsed(offset: 3, affinity: TextAffinity.downstream, isDirectional: false)
flutter: [DEBUG][input]: 2022-10-23 17:59:31.425438: (Instance of 'TextEditingDeltaReplacement')
flutter: [DEBUG][input]: 2022-10-23 17:59:31.425573: receive replacement: text = 问我, composing = TextRange(start: -1, end: -1), selection = TextRange(start: 0, end: 3), old text = w w

Screenshot 2022-10-23 at 18 00 05

Expected results:
I think the behavior for Linux should be the same as macOS.

Actual results:
On Linux, the callback will be like

  1. input w -> receive a replacement action.
  2. input w again -> receive a replacement action again.
  3. press whitespace -> receive an insertion action.

It makes the text will be duplicated.

On macOS, the callback will be like

  1. input w -> receive an insertion action.
  2. input w again -> receive an insertion action again.
  3. press whitespace -> receive a replacement action. Replace the previous characters with the result text.

Flutter Environment
Linux

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, 3.0.5, on Ubuntu 22.04.1 LTS 5.15.0-50-generic, locale en_US.UTF-8)

macOS

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, 3.0.5, on macOS 13.0 22A5358e darwin-arm, locale en-CN)

Metadata

Metadata

Labels

P1High-priority issues at the top of the work lista: desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsc: crashStack traces logged to the consolefound in release: 3.6Found to occur in 3.6frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-linuxBuilding on or for Linux specificallyplatform-webWeb applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions