From 92cead3a1d333994f25cda3ad995b430ea36ca23 Mon Sep 17 00:00:00 2001 From: RyotaUshio Date: Wed, 24 Apr 2024 10:07:40 +0900 Subject: [PATCH] Fix #284 by disabling snippet expansion when IME is on --- package-lock.json | 4 ++-- src/latex_suite.ts | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 296294e..83b5a3f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-latex-suite", - "version": "1.9.1", + "version": "1.9.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "obsidian-latex-suite", - "version": "1.9.1", + "version": "1.9.2", "license": "MIT", "dependencies": { "set.prototype.difference": "^1.1.5", diff --git a/src/latex_suite.ts b/src/latex_suite.ts index 310871f..2a3db6b 100644 --- a/src/latex_suite.ts +++ b/src/latex_suite.ts @@ -37,6 +37,13 @@ export const handleUpdate = (update: ViewUpdate) => { } export const onKeydown = (event: KeyboardEvent, view: EditorView) => { + // Prevent IME from triggering keydown events. + // view.composing and event.isComposing are false for the first keydown event of an IME composition, + // so we need to check for event.keyCode === 229 to prevent IME from triggering keydown events. + // Note that keyCode is deprecated - it is used here because it is apparently the only way to detect the first keydown event of an IME composition. + const isIME = view.composing || event.keyCode === 229; + if (isIME) return; + const success = handleKeydown(event.key, event.shiftKey, event.ctrlKey || event.metaKey, view); if (success) event.preventDefault();