Skip to content

Commit

Permalink
Merge pull request #252 from cgavalos/async-stop
Browse files Browse the repository at this point in the history
Deactivate VSCode extension asynchronously
  • Loading branch information
tgjones committed Jul 30, 2023
2 parents 3638d7f + 1cb6692 commit 3cb3e76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/ShaderTools.VSCode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ var sessionManager: SessionManager = undefined;
export function activate(context: vscode.ExtensionContext): void {
context.subscriptions.push(sessionManager = new SessionManager());
sessionManager.start();
}

export function deactivate(): Promise<void> {
return sessionManager.stop();
}
8 changes: 6 additions & 2 deletions src/ShaderTools.VSCode/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class SessionManager {
this.startEditorServices();
}

public stop() {
public stop(): Promise<void> {
if (this.sessionStatus === SessionStatus.Failed) {
// Before moving further, clear out the client and process if
// the process is already dead (i.e. it crashed)
Expand All @@ -44,13 +44,17 @@ export class SessionManager {

this.sessionStatus = SessionStatus.Stopping;

var promise = Promise.resolve();

// Close the language server client
if (this.languageServerClient !== undefined) {
this.languageServerClient.stop();
promise = this.languageServerClient.stop();
this.languageServerClient = undefined;
}

this.sessionStatus = SessionStatus.NotStarted;

return promise;
}

public dispose() : void {
Expand Down

0 comments on commit 3cb3e76

Please sign in to comment.