Skip to content

Commit

Permalink
fix: prevent CodeMirror from capturing escape key and shortcuts based…
Browse files Browse the repository at this point in the history
… on keymap settings
  • Loading branch information
pavkout committed Feb 13, 2025
1 parent b7e9597 commit 0b5db60
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,17 @@ export const CodeEditor = memo(forwardRef<CodeEditorHandle, CodeEditorProps>(({
});
// Stop the editor from handling global keyboard shortcuts except for the autocomplete binding
const isShortcutButNotAutocomplete = isUserDefinedKeyboardShortcut && !isAutoCompleteBinding;

// Should not capture escape in order to exit modals
const isEscapeKey = event.code === 'Escape';

if (isShortcutButNotAutocomplete) {
// @ts-expect-error -- unsound property assignment
event.codemirrorIgnore = true;
event.codemirrorIgnore = settings.editorKeyMap !== 'vim';
// Stop the editor from handling the escape key
} else if (isEscapeKey) {
// @ts-expect-error -- unsound property assignment
event.codemirrorIgnore = true;
event.codemirrorIgnore = settings.editorKeyMap !== 'vim';
} else {
event.stopPropagation();

Expand Down

0 comments on commit 0b5db60

Please sign in to comment.