Skip to content

Commit

Permalink
Fix artisticat1#284 by disabling snippet expansion when IME is on
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaUshio committed Apr 24, 2024
1 parent 899cc8b commit 92cead3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/latex_suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 92cead3

Please sign in to comment.