diff --git a/package.json b/package.json index 7d5e8bf..fe4bea0 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,27 @@ "command": "devrun-vscode.stopServer", "title": "DevRun: Stop the run server (for quick run starts)" } - ] + ], + "menus": { + "commandPalette": [ + { + "command": "devrun-vscode.startRun", + "when": "!devrun.runActive" + }, + { + "command": "devrun-vscode.stopRun", + "when": "devrun.runActive" + }, + { + "command": "devrun-vscode.startServer", + "when": "!devrun.serverActive" + }, + { + "command": "devrun-vscode.stopServer", + "when": "devrun.serverActive" + } + ] + } }, "scripts": { "vscode:prepublish": "npm run compile", diff --git a/src/run.ts b/src/run.ts index fa245f9..0fc57ae 100644 --- a/src/run.ts +++ b/src/run.ts @@ -53,6 +53,8 @@ export async function startRun( .padStart(2, "0")}`; }, 50), }; + + await vscode.commands.executeCommand("setContext", "devrun.runActive", true); } export async function stopRun() { @@ -60,4 +62,6 @@ export async function stopRun() { clearTimeout(currentRun.interval); currentRun = null; } + + await vscode.commands.executeCommand("setContext", "devrun.runActive", false); } diff --git a/src/server.ts b/src/server.ts index 2e3a329..317875e 100644 --- a/src/server.ts +++ b/src/server.ts @@ -52,6 +52,12 @@ export async function startServer(statusBarItem: vscode.StatusBarItem) { server = app.listen(63780, "127.0.0.1", () => { setTimeout(() => (statusBarItem.text = "$(clock) No active run"), 500); }); + + await vscode.commands.executeCommand( + "setContext", + "devrun.serverActive", + true, + ); } export async function stopServer(statusBarItem: vscode.StatusBarItem) { @@ -67,4 +73,10 @@ export async function stopServer(statusBarItem: vscode.StatusBarItem) { server = undefined; setTimeout(() => (statusBarItem.text = "$(clock) No active run"), 500); + + await vscode.commands.executeCommand( + "setContext", + "devrun.serverActive", + false, + ); }