From 10b9ce915dd38d858803381aa22d2b8c9590b916 Mon Sep 17 00:00:00 2001 From: PraneshBK <44346322+PraneshBalasubramaniam@users.noreply.github.com> Date: Sat, 9 Sep 2023 17:32:38 +0000 Subject: [PATCH] fix: solved 'Throw ball with mouse' option not working in command palatte #375 --- package-lock.json | 4 ++-- package.json | 10 ---------- src/extension/extension.ts | 24 ++++++++++++++++++------ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 590ec723..ca7cb4f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "vscode-pets", - "version": "1.24.0", + "version": "1.25.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "vscode-pets", - "version": "1.24.0", + "version": "1.25.0", "license": "MIT", "dependencies": { "@vscode/l10n": "^0.0.10" diff --git a/package.json b/package.json index 7b1bd459..db8b330f 100644 --- a/package.json +++ b/package.json @@ -29,18 +29,8 @@ "license": "MIT", "icon": "icon.png", "activationEvents": [ - "onCommand:vscode-pets.start", - "onCommand:vscode-pets.throw-with-mouse", - "onCommand:vscode-pets.throw-ball", - "onCommand:vscode-pets.spawn-pet", - "onCommand:vscode-pets.delete-pet", - "onCommand:vscode-pets.remove-all-pets", - "onCommand:vscode-pets.roll-call", - "onCommand:vscode-pets.export-pet-list", - "onCommand:vscode-pets.import-pet-list", "onWebviewPanel:petCoding", "onView:explorer", - "onView:petsView", "onStartupFinished" ], "main": "./out/extension/extension.js", diff --git a/src/extension/extension.ts b/src/extension/extension.ts index 061c42fc..62452046 100644 --- a/src/extension/extension.ts +++ b/src/extension/extension.ts @@ -85,6 +85,14 @@ function getThrowWithMouseConfiguration(): boolean { .get('throwBallWithMouse', true); } +function updateThrowWithMouseConfiguration() { + const config = vscode.workspace + .getConfiguration('vscode-pets'); + const newValue = !config.get('throwBallWithMouse', true); + config + .update('throwBallWithMouse', newValue, vscode.ConfigurationTarget.Global); +} + function updatePanelThrowWithMouse(): void { const panel = getPetPanel(); if (panel !== undefined) { @@ -365,6 +373,12 @@ export function activate(context: vscode.ExtensionContext) { }), ); + context.subscriptions.push( + vscode.commands.registerCommand('vscode-pets.throw-with-mouse', + updateThrowWithMouseConfiguration + ), + ); + context.subscriptions.push( vscode.commands.registerCommand('vscode-pets.delete-pet', async () => { const panel = getPetPanel(); @@ -801,7 +815,7 @@ class PetWebviewContainer implements IPetPanel { webview.html = this._getHtmlForWebview(webview); } - public update() {} + public update() { } protected _getHtmlForWebview(webview: vscode.Webview) { // Local path to main script run in the webview @@ -853,11 +867,9 @@ class PetWebviewContainer implements IPetPanel { Use a content security policy to only allow loading images from https or from our extension directory, and only allow scripts that have a specific nonce. --> -