Skip to content

Commit

Permalink
Improving Installed Keybinding Message (#33)
Browse files Browse the repository at this point in the history
If there are no required extensions, don't offer to install extensions.
  • Loading branch information
haberdashPI authored Sep 29, 2024
1 parent 8c74a7d commit b01929e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Master Key",
"publisher": "haberdashPI",
"description": "Master your keybindings with documentation, discoverability, modal bindings, macros and expressive configuration",
"version": "0.3.5",
"version": "0.3.6",
"icon": "logo.png",
"repository": {
"url": "https://github.com/haberdashPi/vscode-master-key"
Expand Down
15 changes: 12 additions & 3 deletions src/web/keybindings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ async function copyCommandResultIntoBindingFile(command: string) {
}
}

async function insertKeybindingsIntoConfig(name: string, keyBindings: IConfigKeyBinding[]) {
async function insertKeybindingsIntoConfig(bindings: Bindings) {
const name = bindings.name || 'none';
const keyBindings = bindings.bind;

await vscode.commands.executeCommand('workbench.action.openGlobalKeybindingsFile');
const ed = vscode.window.activeTextEditor;
if (ed) {
Expand Down Expand Up @@ -269,6 +272,12 @@ async function insertKeybindingsIntoConfig(name: string, keyBindings: IConfigKey
}

if (installed) {
if ((bindings.requiredExtensions || []).length === 0) {
vscode.window.showInformationMessage(
'Master keybindings were added to `keybindings.json`'
);
return;
}
vscode.window
.showInformationMessage(
replaceAll(
Expand Down Expand Up @@ -536,7 +545,7 @@ async function activateBindings(preset?: Preset) {
const bindings = await createBindings(preset.data);
if (bindings) {
await handleRequireExtensions(bindings);
await insertKeybindingsIntoConfig(bindings.name || 'none', bindings.bind);
await insertKeybindingsIntoConfig(bindings);
await vscode.commands.executeCommand('master-key.showVisualDoc');
await vscode.commands.executeCommand('master-key.showTextDoc');
}
Expand Down Expand Up @@ -569,7 +578,7 @@ async function selectUserBindings(file?: vscode.Uri) {
const data = new TextDecoder().decode(fileData);
const bindings = await createUserBindings(data);
if (bindings) {
await insertKeybindingsIntoConfig(bindings.name || 'none', bindings.bind);
await insertKeybindingsIntoConfig(bindings);
}
}
}
Expand Down

0 comments on commit b01929e

Please sign in to comment.