Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Korean Input Bug (include debugging information) #1028

Open
Jongsik opened this issue Jan 25, 2025 · 3 comments
Open

[Bug] Korean Input Bug (include debugging information) #1028

Jongsik opened this issue Jan 25, 2025 · 3 comments

Comments

@Jongsik
Copy link

Jongsik commented Jan 25, 2025

Bug Description

Hi. I think many korean people has problem with windows 10 korean IME
The details of bug can find here : AppFlowy-IO/AppFlowy#5357 (comment)

it could be reproduced by typing "xptmxm" in QWERTY keyborad

Image

How to Reproduce

  1. appflowy-editor source commit id : 2a03498
  2. just type korean charactors with windows 10 IME

Expected Behavior

It is okay with Windows 11 IME

Image

Operating System

windwos 10 and windows 11(with previous version IME)

AppFlowy Editor Version(s)

4.0.0

Screenshots

No response

Additional Context

Somthing informations during debugging.

  1. WIndows 10 IME vs Windows 11 IME
  • WIndows message's order is different.
  • windows 11 IME
    --> WM_IME_STARTCOMPOSITION
    --> WM_IME_COMPOSITION – (lParam & GCS_COMPSTR)
    --> WM_IME_COMPOSITION – (lParam & GCS_RESULTSTR)
    --> WM_IME_ENDCOMPOSITION
  • windows 10 IME
    --> WM_IME_STARTCOMPOSITION
    --> WM_IME_COMPOSITION – (lParam & GCS_COMPSTR)
    --> WM_IME_ENDCOMPOSITION
    --> WM_IME_COMPOSITION – (lParam & GCS_RESULTSTR)
  1. appflowy debbuging messages
  • Windows 10 IME (NOK)
    -->TextEditingDeltaReplacement
    -->TextEditingDeltaInsertion
    --> apply op (local): {op: update, ~~
  • Windows 11 IME (OK)
    -->TextEditingDeltaReplacement
    -->TextEditingDeltaNonTextUpdate
    -->TextEditingDeltaNonTextUpdate
    -->TextEditingDeltaInsertion
    --> apply op (local): {op: update, ~~
  1. The direct cause of the bug
  • I checked "onInsert" function In "delta_input_on_insert_impl.dart" file
  • At the line 75, the blow codes could be found.
    final transaction = editorState.transaction
    ..insertText(
    node,
    selection.startIndex,
    textInserted,
    toggledAttributes: editorState.toggledStyle,
    sliceAttributes: editorState.sliceUpcomingAttributes,
    )
  • In "insertText" function and line 228 of "transaction.dart" file,
    final insert = Delta()
    ..retain(index) <<-- windows 10 IME Skip this when problem is occured
    ..insert(text, attributes: newAttributes);
  • The main reason is "selection.startIndex" is different beteewn windows 10 IME and 11 IME

I found thease phenomenons, but i couldn't find the way to fix this.
Please Check this bug. Thanks.

@asjqkkkk
Copy link
Contributor

Hi @Jongsik , thanks for your issue, if it's convenient for you, could you please provide the detailed information for the following part? For example, the actual data of various TextEditingDelta instances?

Windows 10 IME (NOK)
-->TextEditingDeltaReplacement
-->TextEditingDeltaInsertion
--> apply op (local): {op: update, ~~
Windows 11 IME (OK)
-->TextEditingDeltaReplacement
-->TextEditingDeltaNonTextUpdate
-->TextEditingDeltaNonTextUpdate
-->TextEditingDeltaInsertion
--> apply op (local): {op: update, ~~

@Jongsik
Copy link
Author

Jongsik commented Jan 26, 2025

@asjqkkkk Thank you for your reply.
more details.

If i type the word "스트", the order of typing is,

  1. "스" ("tm" in QWERTY keyborad) --> "슽" ("tme") --> "스트" ("tmxm")
  2. Windows 10 Result : "스트"
  3. Windows 11 Result : "트스" (The order is converted)

The detail logs

  1. Windows 10 IME (NOK)

flutter: [DEBUG][input]: 2025-01-26 11:59:02.796186: onReplace: TextEditingDeltaReplacement#30dcf(oldText: 스, textReplaced: 스, replacementText: 슽, replacedRange: TextRange(start: 0, end: 1), selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 1))
flutter: [DEBUG][editor]: 2025-01-26 11:59:02.798214: apply op (local): {op: update, path: [5], attributes: {delta: [{insert: 슽}]}, oldAttributes: {delta: [{insert: 스}]}}
flutter: [DEBUG][editor]: 2025-01-26 11:59:02.799213: keyboard service - attach text input service: TextEditingValue(text: ┤슽├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 1))
flutter: [DEBUG][editor]: 2025-01-26 11:59:02.800216: keyboard service - selection changed: start = path = [5], offset = 0, end = path = [5], offset = 0
flutter: [DEBUG][editor]: 2025-01-26 11:59:02.805328: node is rebuilding...: type: paragraph
flutter: [DEBUG][editor]: 2025-01-26 11:59:03.000289: Seal history item
flutter: [DEBUG][input]: 2025-01-26 11:59:05.375858: onReplace: TextEditingDeltaReplacement#b6579(oldText: 슽, textReplaced: 슽, replacementText: 스, replacedRange: TextRange(start: 0, end: 1), selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 1))
flutter: [DEBUG][editor]: 2025-01-26 11:59:05.375858: apply op (local): {op: update, path: [5], attributes: {delta: [{insert: 스}]}, oldAttributes: {delta: [{insert: 슽}]}}
flutter: [DEBUG][editor]: 2025-01-26 11:59:05.376858: keyboard service - attach text input service: TextEditingValue(text: ┤스├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 1))
flutter: [DEBUG][editor]: 2025-01-26 11:59:05.376858: keyboard service - selection changed: start = path = [5], offset = 0, end = path = [5], offset = 0
flutter: [DEBUG][input]: 2025-01-26 11:59:05.377857: onInsert: TextEditingDeltaInsertion#c9f02(oldText: 스, textInserted: 트, insertionOffset: 1, selection: TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 1, end: 2))
flutter: [DEBUG][editor]: 2025-01-26 11:59:05.378860: apply op (local): {op: update, path: [5], attributes: {delta: [{insert: 트스}]}, oldAttributes: {delta: [{insert: 스}]}}
flutter: [DEBUG][editor]: 2025-01-26 11:59:05.378860: keyboard service - attach text input service: TextEditingValue(text: ┤트스├, selection: TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 2))
flutter: [DEBUG][input]: 2025-01-26 11:59:05.379859: attach text editing value: TextEditingValue(text: ┤트스├, selection: TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 2))
flutter: [DEBUG][editor]: 2025-01-26 11:59:05.380908: keyboard service - selection changed: start = path = [5], offset = 1, end = path = [5], offset = 1

2 .windows 11 IME (OK)

Flutter: [DEBUG][input]: 2025-01-26 11:57:46.825279: onReplace: TextEditingDeltaReplacement#1b5c4(oldText: 스, textReplaced: 스, replacementText: 슽, replacedRange: TextRange(start: 0, end: 1), selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 1))
flutter: [DEBUG][editor]: 2025-01-26 11:57:46.826268: apply op (local): {op: update, path: [5], attributes: {delta: [{insert: 슽}]}, oldAttributes: {delta: [{insert: 스}]}}
flutter: [DEBUG][editor]: 2025-01-26 11:57:46.826268: keyboard service - attach text input service: TextEditingValue(text: ┤슽├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 1))
flutter: [DEBUG][editor]: 2025-01-26 11:57:46.827419: keyboard service - selection changed: start = path = [5], offset = 0, end = path = [5], offset = 0
flutter: [DEBUG][editor]: 2025-01-26 11:57:46.840428: node is rebuilding...: type: paragraph
flutter: [DEBUG][editor]: 2025-01-26 11:57:47.028846: Seal history item
flutter: [DEBUG][input]: 2025-01-26 11:57:52.833357: onReplace: TextEditingDeltaReplacement#632ff(oldText: 슽, textReplaced: 슽, replacementText: 스, replacedRange: TextRange(start: 0, end: 1), selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 1))
flutter: [DEBUG][editor]: 2025-01-26 11:57:52.834354: apply op (local): {op: update, path: [5], attributes: {delta: [{insert: 스}]}, oldAttributes: {delta: [{insert: 슽}]}}
flutter: [DEBUG][editor]: 2025-01-26 11:57:52.835349: keyboard service - attach text input service: TextEditingValue(text: ┤스├, selection: TextSelection.collapsed(offset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 0, end: 1))
flutter: [DEBUG][editor]: 2025-01-26 11:57:52.836623: keyboard service - selection changed: start = path = [5], offset = 0, end = path = [5], offset = 0
flutter: [DEBUG][input]: 2025-01-26 11:57:52.839157: onNonTextUpdate: TextEditingDeltaNonTextUpdate#d2647(oldText: 스, selection: TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: [DEBUG][input]: 2025-01-26 11:57:52.842105: last character is not backtick
flutter: [DEBUG][editor]: 2025-01-26 11:57:52.843110: keyboard service - attach text input service: TextEditingValue(text: ┤스├, selection: TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))
flutter: [DEBUG][editor]: 2025-01-26 11:57:52.846247: keyboard service - selection changed: start = path = [5], offset = 1, end = path = [5], offset = 1
flutter: [DEBUG][input]: 2025-01-26 11:57:52.847563: onNonTextUpdate: TextEditingDeltaNonTextUpdate#30e26(oldText: 스, selection: TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 1, end: 1))
flutter: [DEBUG][input]: 2025-01-26 11:57:52.848819: last character is not backtick
flutter: [DEBUG][input]: 2025-01-26 11:57:52.850495: onInsert: TextEditingDeltaInsertion#bcd41(oldText: 스, textInserted: 트, insertionOffset: 1, selection: TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 1, end: 2))
flutter: [DEBUG][editor]: 2025-01-26 11:57:52.852684: apply op (local): {op: update, path: [5], attributes: {delta: [{insert: 스트}]}, oldAttributes: {delta: [{insert: 스}]}}
flutter: [DEBUG][editor]: 2025-01-26 11:57:52.853726: keyboard service - attach text input service: TextEditingValue(text: ┤스트├, selection: TextSelection.collapsed(offset: 1, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: 1, end: 2))
flutter: [DEBUG][editor]: 2025-01-26 11:57:52.854697: keyboard service - selection changed: start = path = [5], offset = 1, end = path = [5], offset = 1
flutter: [DEBUG][editor]: 2025-01-26 11:57:52.860716: node is rebuilding...: type: paragraph

Thanks a lot and if you need more, Please comment me !

@asjqkkkk
Copy link
Contributor

@Jongsik thank you, the information you provided is enough, the next step we need to do is to debug and fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants