mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-11-13 10:17:02 +03:00
clean up duplicated code, created an array of all bound keys in configuration for reference
This commit is contained in:
parent
14a1e97b33
commit
d1ad68ad7d
@ -261,10 +261,15 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
let bracketedKey = AngleBracketNotation.Normalize(keyToBeBound);
|
||||
|
||||
// Register the keybinding
|
||||
// Store registered key bindings in bracket notation form
|
||||
Configuration.boundKeyCombinations.push(bracketedKey);
|
||||
|
||||
registerCommand(context, keybinding.command, () => handleKeyEvent(`${ bracketedKey }`));
|
||||
}
|
||||
|
||||
// Update configuration now that bound keys array is populated
|
||||
Configuration.updateConfiguration();
|
||||
|
||||
// Initialize mode handler for current active Text Editor at startup.
|
||||
if (vscode.window.activeTextEditor) {
|
||||
let mh = await getAndUpdateModeHandler();
|
||||
|
@ -3,7 +3,6 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { taskQueue } from '../../src/taskQueue';
|
||||
import { Globals } from '../../src/globals';
|
||||
import { AngleBracketNotation } from '../../src/notation';
|
||||
|
||||
export type OptionValue = number | string | boolean;
|
||||
export type ValueMapping = {
|
||||
@ -68,23 +67,7 @@ class ConfigurationClass {
|
||||
const handleKeys = vscode.workspace.getConfiguration('vim')
|
||||
.get<IHandleKeys[]>("handleKeys", []);
|
||||
|
||||
let pkg = require(__dirname + '/../../../package.json');
|
||||
|
||||
for (let keybinding of pkg.contributes.keybindings) {
|
||||
let keyToBeBound = "";
|
||||
|
||||
/**
|
||||
* On OSX, handle mac keybindings if we specified one.
|
||||
*/
|
||||
if (process.platform === "darwin") {
|
||||
keyToBeBound = keybinding.mac || keybinding.key;
|
||||
} else if (process.platform === "linux") {
|
||||
keyToBeBound = keybinding.linux || keybinding.key;
|
||||
} else {
|
||||
keyToBeBound = keybinding.key;
|
||||
}
|
||||
|
||||
let bracketedKey = AngleBracketNotation.Normalize(keyToBeBound);
|
||||
for (let bracketedKey of this.boundKeyCombinations) {
|
||||
// Set context for key that is not used
|
||||
// This either happens when user sets useCtrlKeys to false (ctrl keys are not used then)
|
||||
// Or if user usese vim.handleKeys configuration option to set certain combinations to false
|
||||
@ -219,6 +202,11 @@ class ConfigurationClass {
|
||||
relativenumber: boolean;
|
||||
|
||||
iskeyword: string = "/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?-";
|
||||
|
||||
/**
|
||||
* Array of all key combinations that were registered in angle bracket notation
|
||||
*/
|
||||
boundKeyCombinations: string[] = [];
|
||||
}
|
||||
|
||||
function overlapSetting(args: { codeName: string, default: OptionValue, codeValueMapping?: ValueMapping }) {
|
||||
|
Loading…
Reference in New Issue
Block a user