Skip to content

Commit 87bf03c

Browse files
authored
vscode: restart server command (#808)
1 parent 9e83742 commit 87bf03c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

squawk-vscode/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@
6565
"command": "squawk.stopServer",
6666
"title": "Stop Server",
6767
"category": "Squawk"
68+
},
69+
{
70+
"command": "squawk.restartServer",
71+
"title": "Restart Server",
72+
"category": "Squawk"
6873
}
6974
],
7075
"languages": [

squawk-vscode/src/extension.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ export async function activate(context: vscode.ExtensionContext) {
144144
}),
145145
)
146146

147+
context.subscriptions.push(
148+
vscode.commands.registerCommand("squawk.restartServer", async () => {
149+
await restartServer(context)
150+
}),
151+
)
152+
147153
context.subscriptions.push(onClientStateChange)
148154

149155
await startServer(context)
@@ -311,6 +317,12 @@ async function stopServer() {
311317
log.info("server stopped")
312318
}
313319

320+
async function restartServer(context: vscode.ExtensionContext) {
321+
log.info("restart server")
322+
await stopServer()
323+
await startServer(context)
324+
}
325+
314326
// Based on rust-analyzer's SyntaxTree support:
315327
// https://github.com/rust-lang/rust-analyzer/blob/c0eaff7dd1fdfffed4e5706780e79967760d1d9b/editors/code/src/commands.ts#L432-L510
316328
class SyntaxTreeProvider implements vscode.TextDocumentContentProvider {

0 commit comments

Comments
 (0)