Skip to content

Commit aa0e314

Browse files
authored
(fix) Throttle restarting the language server
If another restart happens while a restart is already in progress, VS Code trips up and shows error messages
1 parent 6a5ad09 commit aa0e314

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/svelte-vscode/src/extension.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,21 @@ export function activate(context: ExtensionContext) {
143143
})
144144
);
145145

146+
let restartingLs = false;
146147
async function restartLS(showNotification: boolean) {
148+
if (restartingLs) {
149+
return;
150+
}
151+
152+
restartingLs = true;
147153
await ls.stop();
148154
ls = createLanguageServer(serverOptions, clientOptions);
149155
context.subscriptions.push(ls.start());
150156
await ls.onReady();
151157
if (showNotification) {
152158
window.showInformationMessage('Svelte language server restarted.');
153159
}
160+
restartingLs = false;
154161
}
155162

156163
function getLS() {

0 commit comments

Comments
 (0)