diff --git a/squawk-vscode/package.json b/squawk-vscode/package.json index f45711bb..aa027b44 100644 --- a/squawk-vscode/package.json +++ b/squawk-vscode/package.json @@ -65,6 +65,11 @@ "command": "squawk.stopServer", "title": "Stop Server", "category": "Squawk" + }, + { + "command": "squawk.restartServer", + "title": "Restart Server", + "category": "Squawk" } ], "languages": [ diff --git a/squawk-vscode/src/extension.ts b/squawk-vscode/src/extension.ts index bac1fc70..d1dadc79 100644 --- a/squawk-vscode/src/extension.ts +++ b/squawk-vscode/src/extension.ts @@ -144,6 +144,12 @@ export async function activate(context: vscode.ExtensionContext) { }), ) + context.subscriptions.push( + vscode.commands.registerCommand("squawk.restartServer", async () => { + await restartServer(context) + }), + ) + context.subscriptions.push(onClientStateChange) await startServer(context) @@ -311,6 +317,12 @@ async function stopServer() { log.info("server stopped") } +async function restartServer(context: vscode.ExtensionContext) { + log.info("restart server") + await stopServer() + await startServer(context) +} + // Based on rust-analyzer's SyntaxTree support: // https://github.com/rust-lang/rust-analyzer/blob/c0eaff7dd1fdfffed4e5706780e79967760d1d9b/editors/code/src/commands.ts#L432-L510 class SyntaxTreeProvider implements vscode.TextDocumentContentProvider {