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

Adding characters before the cursor while composing with IME results in offset of characters from IME #1472

Closed
mikecat opened this issue Nov 15, 2024 · 2 comments

Comments

@mikecat
Copy link

mikecat commented Nov 15, 2024

Describe the issue

  1. start composing with an IME on some position
  2. add some characters before the cursor
  3. hit Enter key to have the IME insert composed characters

As a result, the inserted characters appear before where they are expected.
They looks like being inserted using the original number of characters from the beginning of the document, regardless of the inserted characters.
This may result in some trouble in, for example, a collaborative editor application where multiple users concurrently write something.

This happened with Google Chrome 131.0.6778.70 and Microsoft Edge 131.0.2903.48, with Google 日本語入力 and Microsoft IME.

This is an example with Google Chrome:

2024-11-15.085747.mp4

On the other hand, this didn't happen on Firefox 132.0.2:

2024-11-15.085641.mp4

Browser and platform

Google Chrome, Microsoft Edge

Reproduction link

https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgoKY29uc3QgdmlldyA9IG5ldyBFZGl0b3JWaWV3KHsKICBkb2M6ICJ0ZXN0XG5cbmhvZ2VcbiIsCiAgZXh0ZW5zaW9uczogW2Jhc2ljU2V0dXBdLAogIHBhcmVudDogZG9jdW1lbnQuYm9keQp9KQoKc2V0SW50ZXJ2YWwoKCkgPT4gewogIHZpZXcuZGlzcGF0Y2goe2NoYW5nZXM6IHtmcm9tOiAwLCBpbnNlcnQ6ICJ0In19KTsKfSwgNTAwMCk7Cg==

@marijnh
Copy link
Member

marijnh commented Nov 15, 2024

It seems I was expecting too much from Chrome's EditContext implementation. I've opened an issue about it, but that will probably not get addressed all that quickly. So I'm going to see if I can work around this in the library for the time being.

@marijnh
Copy link
Member

marijnh commented Nov 15, 2024

Attached patch kludges around this until this is handled better on the browser's side.

See also w3c/edit-context#111

marijnh added a commit to codemirror/view that referenced this issue Dec 4, 2024
FIX: Work around another crash caused by incorrect composition positions
reported by `EditContext`.

See https://discuss.codemirror.net/t/editor-crashing-when-used-as-controlled-component-in-react/8457
Issue codemirror/dev#1472
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