From c050b6c5ca71c4bdb81a18724fff097d58b04ffe Mon Sep 17 00:00:00 2001 From: tshino Date: Tue, 30 Nov 2021 20:48:13 +0900 Subject: [PATCH] Update gen_keymap_wrapper.js #11 --- generator/gen_keymap_wrapper.js | 29 +++++++-------- .../tshino.vz-like-keymap.config.json | 35 +++++++++++++++++-- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/generator/gen_keymap_wrapper.js b/generator/gen_keymap_wrapper.js index 097170eb..00df8944 100644 --- a/generator/gen_keymap_wrapper.js +++ b/generator/gen_keymap_wrapper.js @@ -33,20 +33,21 @@ function makeWrapper(keybinding) { } function resolveWildcardInAwaitOptions(awaitOptions, baseKeybindings) { - const wildcardCommands = Array.from(awaitOptions.keys()).filter( - command => command.endsWith('*') - ); - for (const wildcard of wildcardCommands) { - const awaitOption = awaitOptions.get(wildcard); - const prefix = wildcard.slice(0, -1); - const matches = baseKeybindings.filter( - keybinding => keybinding.command.startsWith(prefix) - ).map(keybinding => keybinding.command); - for (const match of matches) { - awaitOptions.set(match, awaitOption); + const newAwaitOptions = new Map; + for (const [ command, awaitOption ] of awaitOptions) { + if (command.endsWith('*')) { // wildcard + const prefix = command.slice(0, -1); + const matches = baseKeybindings.filter( + keybinding => keybinding.command.startsWith(prefix) + ).map(keybinding => keybinding.command); + for (const match of matches) { + newAwaitOptions.set(match, awaitOption); + } + } else { + newAwaitOptions.set(command, awaitOption); } - awaitOptions.delete(wildcard); } + return newAwaitOptions; } async function makeKeymapWrapper(configPath) { @@ -58,11 +59,11 @@ async function makeKeymapWrapper(configPath) { const config = await genWrapperUtil.readJSON(configPath); const exclusion = new Set(config['exclusion'] || []); - const awaitOptions = new Map(config['awaitOptions'] || []); const baseKeybindings = packageJson['contributes']['keybindings']; - resolveWildcardInAwaitOptions(awaitOptions, baseKeybindings); + const rawAwaitOptions = new Map(config['awaitOptions'] || []); + const awaitOptions = resolveWildcardInAwaitOptions(rawAwaitOptions, baseKeybindings); const wrappers = baseKeybindings.map( keybinding => { diff --git a/keymap-wrapper/tshino.vz-like-keymap.config.json b/keymap-wrapper/tshino.vz-like-keymap.config.json index 8cebeaf6..060e8b72 100644 --- a/keymap-wrapper/tshino.vz-like-keymap.config.json +++ b/keymap-wrapper/tshino.vz-like-keymap.config.json @@ -3,6 +3,27 @@ "githubRepoURL": "https://github.com/tshino/vscode-vz-like-keymap" }, + "exclusion": [ + "editor.action.triggerSuggest", + "hideSuggestWidget", + "selectNextSuggestion", + "selectPrevSuggestion", + "selectNextPageSuggestion", + "selectPrevPageSuggestion", + "toggleExplainMode", + "toggleSuggestionDetails", + "toggleSuggestionFocus", + "acceptSelectedSuggestion", + "acceptAlternativeSelectedSuggestion", + "insertSnippet", + "leaveSnippet", + "editor.action.insertSnippet", + "jumpToNextSnippetPlaceholder", + "jumpToPrevSnippetPlaceholder", + "workbench.action.showCommands", + "showPrevParameterHint", + "showNextParameterHint" + ], "awaitOptions": [ [ "vz.cursor*", "selection" ], [ "vz.scroll*", "selection" ], @@ -15,7 +36,7 @@ [ "vz.delete*", "document selection" ], [ "vz.insert*", "document selection" ], - [ "vz.copy*", "document selection" ], + [ "vz.copyLines*", "document selection" ], [ "vz.transform*", "document selection" ], [ "vz.undelete", "document selection" ], [ "tab", "document selection" ], @@ -30,6 +51,16 @@ [ "undo", "document selection" ], [ "vz.undo", "document selection" ], [ "redo", "document selection" ], - [ "vz.redo", "document selection" ] + [ "vz.redo", "document selection" ], + + [ "history.show*", "selection" ], + [ "vz.findStart*", "selection" ], + [ "vz.findStartEnter", "document selection" ], + [ "vz.findPreviousMatch", "selection" ], + [ "vz.findNextMatch", "selection" ], + [ "vz.selectWordToFind", "selection" ], + [ "vz.expandWordToFind", "selection" ], + [ "vz.replaceOne", "document selection" ], + [ "vz.closeFindWidget", "selection" ] ] }