diff --git a/CHANGELOG.md b/CHANGELOG.md index a7a115ce9..a76de425b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Change Log All notable changes to the "emacs-mcx" extension will be documented in this file. +## [Unreleased] +### Fixed +- Disable Emacs-like cursor movements when the find or replace widgets are focused on Windows, because the cursor on the OS native UIs cannot be controlled by extensions. + ## [0.28.0] - 2021-04-09 ### Added - Add `C-x C-c`. diff --git a/keybinding-generator/generate-keybindings.ts b/keybinding-generator/generate-keybindings.ts index 877880921..2a3a70dfb 100644 --- a/keybinding-generator/generate-keybindings.ts +++ b/keybinding-generator/generate-keybindings.ts @@ -1,7 +1,7 @@ export interface KeyBindingSource { key?: string; keys?: string[]; - command: string; + command?: string; when?: string; whens?: string[]; args?: (string | number)[]; @@ -10,7 +10,7 @@ export interface KeyBindingSource { export interface KeyBinding { key?: string; mac?: string; - command: string; + command?: string; when?: string; args?: (string | number)[]; } @@ -111,7 +111,7 @@ export function generateKeybindings(src: KeyBindingSource): KeyBinding[] { // Generate keybindings using ESC and Ctrl+[ as meta. const keystrokes = key.split(" ").filter((k) => k); if (keystrokes.length === 1) { - const keyWithEscapeMeta = replaceMetaWithEscape(key) + const keyWithEscapeMeta = replaceMetaWithEscape(key); keybindings.push({ key: keyWithEscapeMeta, command: src.command, @@ -129,7 +129,6 @@ export function generateKeybindings(src: KeyBindingSource): KeyBinding[] { `"${key}" includes more than one key strokes then it's meta key specification cannot be converted to "ESC" and "ctrl+[".` ); } - } else { keybindings.push({ key, @@ -161,7 +160,7 @@ export function isKeyBindingSource(maybeSrc: { [key: string]: any }): maybeSrc i } // Check for .command - if (typeof maybeSrc.command !== "string") { + if (typeof maybeSrc.command !== "undefined" && typeof maybeSrc.command !== "string") { return false; } @@ -244,12 +243,12 @@ export function generateKeybindingsForPrefixArgument(): KeyBinding[] { keybindings.push({ key: "enter", command: "emacs-mcx.newLine", - when: "emacs-mcx.prefixArgumentExists && editorTextFocus && !editorReadonly" + when: "emacs-mcx.prefixArgumentExists && editorTextFocus && !editorReadonly", }); keybindings.push({ key: "backspace", command: "emacs-mcx.deleteBackwardChar", - when: "emacs-mcx.prefixArgumentExists && editorTextFocus && !editorReadonly" + when: "emacs-mcx.prefixArgumentExists && editorTextFocus && !editorReadonly", }); return keybindings; diff --git a/keybindings.json b/keybindings.json index 32bc43dbb..fa755707f 100644 --- a/keybindings.json +++ b/keybindings.json @@ -301,6 +301,38 @@ "command": "editor.action.startFindReplaceAction", "when": "editorFocus" }, + // Disable Emacs-like keybindings on the find and replace widgets (native UI). + // See https://github.com/whitphx/vscode-emacs-mcx/issues/55 + { + "keys": [ + "ctrl+f", + "ctrl+b", + "ctrl+p", + "ctrl+n", + "ctrl+a", + "ctrl+e", + "alt+f", + "alt+b", + "alt+m", + "ctrl+d", + "ctrl+h", + "alt+d", + "ctrl+k", + "ctrl+w", + "alt+w", + "ctrl+y", + "alt+y", + "ctrl+m", + "ctrl+j", + "alt+l", + "alt+u", + "alt+backspace" + ], + "whens": [ + "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing", + "isWindows && replaceInputFocussed && !isComposing" + ] + }, // addSelectionToNext/PreviousFindMatch { "key": "ctrl+meta+n", diff --git a/package.json b/package.json index 499f3d7c1..2d6eb0add 100644 --- a/package.json +++ b/package.json @@ -1811,6 +1811,182 @@ "command": "editor.action.startFindReplaceAction", "when": "editorFocus && config.emacs-mcx.useMetaPrefixCtrlLeftBracket" }, + { + "key": "ctrl+f", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+b", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+p", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+n", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+a", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+e", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "alt+f", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "alt+b", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "alt+m", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+d", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+h", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "alt+d", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+k", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+w", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "alt+w", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+y", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "alt+y", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+m", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+j", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "alt+l", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "alt+u", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "alt+backspace", + "when": "isWindows && config.emacs-mcx.cursorMoveOnFindWidget && findInputFocussed && !isComposing" + }, + { + "key": "ctrl+f", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+b", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+p", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+n", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+a", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+e", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "alt+f", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "alt+b", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "alt+m", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+d", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+h", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "alt+d", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+k", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+w", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "alt+w", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+y", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "alt+y", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+m", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "ctrl+j", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "alt+l", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "alt+u", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, + { + "key": "alt+backspace", + "when": "isWindows && replaceInputFocussed && !isComposing" + }, { "key": "ctrl+alt+n", "command": "emacs-mcx.addSelectionToNextFindMatch",