Skip to content

Commit 0e44e99

Browse files
committed
fix: prevent hotkeys when typing in monaco editor
1 parent c87d474 commit 0e44e99

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/client/setup/monaco.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/comm
2020
import ts from 'typescript'
2121
import { watchEffect } from 'vue'
2222
import { isDark } from '../logic/dark'
23+
import { shortcutsEnabled } from '../state'
2324

2425
window.MonacoEnvironment = {
2526
getWorker(_, label) {
@@ -97,6 +98,18 @@ const setup = createSingletonPromise(async () => {
9798
Object.assign(editorOptions, result?.editorOptions)
9899
}
99100

101+
// Disable shortcuts when focusing Monaco editor.
102+
monaco.editor.onDidCreateEditor((editor) => {
103+
let areShortcutsEnabled = shortcutsEnabled.value
104+
editor.onDidFocusEditorWidget(() => {
105+
areShortcutsEnabled = shortcutsEnabled.value
106+
shortcutsEnabled.value = false
107+
})
108+
editor.onDidBlurEditorWidget(() => {
109+
shortcutsEnabled.value = areShortcutsEnabled
110+
})
111+
})
112+
100113
// Use Shiki to highlight Monaco
101114
shikiToMonaco(highlighter, monaco)
102115
if (typeof themes === 'string') {

0 commit comments

Comments
 (0)