diff --git a/packages/insomnia/src/ui/components/codemirror/code-editor.tsx b/packages/insomnia/src/ui/components/codemirror/code-editor.tsx index aa95273a93a..9d90bfcffa4 100644 --- a/packages/insomnia/src/ui/components/codemirror/code-editor.tsx +++ b/packages/insomnia/src/ui/components/codemirror/code-editor.tsx @@ -413,15 +413,17 @@ export const CodeEditor = memo(forwardRef(({ }); // 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();