Skip to content

Fix composition logic for Firefox#106873

Merged
rebornix merged 3 commits intomicrosoft:masterfrom
belcherj:patch-1
Nov 6, 2020
Merged

Fix composition logic for Firefox#106873
rebornix merged 3 commits intomicrosoft:masterfrom
belcherj:patch-1

Conversation

@belcherj
Copy link
Contributor

Fixes: #106392

In Firefox when inserting Emoji's using the macOS emoji input or using the compositor for characters with accents è, ë, î, etc. the character is inserted twice. Additionally, when adding an accented character the base character was also inserted.

Examples:

🏅 inserts 🏅🏅
è inserts eèè

This change does two things:

  • It removes this._onType.fire(typeInput); from the compositionupdate event listener. If you are in the middle of a composition there is no need to fire off the event. This change fixes the unaccented character from being inserted. è no longer inserts .

  • In the composition end function browser.isFirefox is added to the conditional that resets this._textAreaState to the value of the text area. This is needed as the insert of the composition is handled by L294. The textarea needs to be updated correctly when the compositions ends.

Tested in Firefox (Windows 10, Ubuntu, macOS), Safari (macOS), Chrome (macOS), Edge Legacy (Windows 10), Edge (Windows 10)

This PR fixes #

Fixes: #106392

In Firefox when inserting Emoji's using the macOS emoji input or using the compositor for characters with accents è, ë, î, etc. the character is inserted twice. Additionally, when adding an accented character the base character was also inserted.

Examples:

🏅 inserts 🏅🏅
è inserts eèè

This change does two things:

- It removes `this._onType.fire(typeInput);` from the compositionupdate event listener. If you are in the middle of a composition there is no need to fire off the event. This change fixes the unaccented character from being inserted. `è` no longer inserts `eè`.

- In the composition end function `browser.isFirefox` is added to the conditional that resets this._textAreaState to the value of the text area. This is needed as the insert of the composition is handled by L294. The textarea needs to be updated correctly when the compositions ends.

Tested in Firefox (Windows 10, Ubuntu, macOS), Safari (macOS), Chrome (macOS), Edge Legacy (Windows 10), Edge (Windows 10)
textInput is no longer used. This removes the declaration as it is not used or needed.
@belcherj belcherj marked this pull request as ready for review September 16, 2020 19:47
@alexdima
Copy link
Member

Just a reminder, for changes in this area we need to go through all the input modes documented at https://github.com/microsoft/vscode/wiki/IME-Test

@rebornix Could you please also help to test this? I think removing this._onType.fire(typeInput); from the compositionupdate will break CJK input.

@belcherj
Copy link
Contributor Author

Alex, thank you for taking a look. I will work through the tests in that doc as well.

@rebornix rebornix self-assigned this Sep 24, 2020
@rebornix
Copy link
Member

I gave it a test on macOS and found it changed the behavior of Japanese IME in both Safari and Firefox, meaning that removing this._onType.fire(typeInput); changes the behavior

One example:

  • Install Japanese IME
  • Switch to Hiragana
  • Open VS Code Insiders, type watashi, press enter, type watashi again, press enter
  • You will get 私私
  • With this change, type watashi, press enter, you will get . And then press watashi again, press enter, it ends up with . Somehow the second is omitted.

@rebornix rebornix added this to the October 2020 milestone Sep 28, 2020
@rebornix
Copy link
Member

I'll take a closer look at why this breaks CJK in October, thanks for your help @belcherj !

@rebornix rebornix added bug Issue identified by VS Code Team member as probable bug editor-input-IME Editor input of characters not on keyboard firefox Issues running VSCode in Web on Firefox labels Oct 8, 2020
@rebornix rebornix modified the milestones: October 2020, November 2020 Oct 30, 2020
@rebornix
Copy link
Member

rebornix commented Nov 6, 2020

Tested that if (browser.isEdge || browser.isChrome|| browser.isFirefox) { can solve the Firefox but without breaking other browsers. Thanks for your help!

@rebornix rebornix merged commit 83f000d into microsoft:master Nov 6, 2020
@belcherj belcherj deleted the patch-1 branch November 9, 2020 15:20
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Issue identified by VS Code Team member as probable bug editor-input-IME Editor input of characters not on keyboard firefox Issues running VSCode in Web on Firefox

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emoji get inserted twice in OSX Firefox

3 participants