From dfce5b57a085d1fc53746bfd0b1a2a231c66efb3 Mon Sep 17 00:00:00 2001 From: Masaki Muranaka Date: Mon, 2 Dec 2019 18:13:30 +0900 Subject: [PATCH] [hotfix] Stop dispatching to keybindings in editing coposition text. Signed-off-by: Masaki Muranaka --- .../core/src/browser/frontend-application.ts | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/packages/core/src/browser/frontend-application.ts b/packages/core/src/browser/frontend-application.ts index 480f5657d149f..d8db377935205 100644 --- a/packages/core/src/browser/frontend-application.ts +++ b/packages/core/src/browser/frontend-application.ts @@ -157,17 +157,42 @@ export class FrontendApplication { return startupElements.length === 0 ? undefined : startupElements[0] as HTMLElement; } + /* vvv HOTFIX begin vvv + * + * This is a hotfix against issues eclipse/theia#6459 and gitpod-io/gitpod#875 . + * It should be reverted after Theia was updated to the newer Monaco. + */ + protected inComposition = false; + /** + * Register composition related event listeners. + */ + protected registerComositionEventListeners(): void { + window.document.addEventListener('compositionstart', event => { + this.inComposition = true; + }); + window.document.addEventListener('compositionend', event => { + this.inComposition = false; + }); + } + /* ^^^ HOTFIX end ^^^ */ + /** * Register global event listeners. */ protected registerEventListeners(): void { + this.registerComositionEventListeners(); /* Hotfix. See above. */ + window.addEventListener('beforeunload', () => { this.stateService.state = 'closing_window'; this.layoutRestorer.storeLayout(this); this.stopContributions(); }); window.addEventListener('resize', () => this.shell.update()); - document.addEventListener('keydown', event => this.keybindings.run(event), true); + document.addEventListener('keydown', event => { + if (this.inComposition !== true) { + this.keybindings.run(event); + } + }, true); document.addEventListener('touchmove', event => { event.preventDefault(); }, { passive: false }); // Prevent forward/back navigation by scrolling in OS X if (isOSX) {