Skip to content

Commit

Permalink
Fix check for clangd.restart being a no-op (#601)
Browse files Browse the repository at this point in the history
The intention was to only catch the case where the language server
is already starting because running the restart command triggered
activation of the plugin, but it was also catching the case where
the language server wasn't running at all.

Fixes #599
  • Loading branch information
HighCommander4 authored Mar 19, 2024
1 parent a3925bb commit 900eccb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/clangd-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ export class ClangdContext implements vscode.Disposable {
(e) => isClangdDocument(e.document));
}

clientIsReady() {
return this.client && this.client.state == vscodelc.State.Running;
clientIsStarting() {
return this.client && this.client.state == vscodelc.State.Starting;
}

dispose() {
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function activate(context: vscode.ExtensionContext) {
// stop/start cycle in this situation is pointless, and doesn't work
// anyways because the client can't be stop()-ped when it's still in the
// Starting state).
if (!clangdContext.clientIsReady()) {
if (clangdContext.clientIsStarting()) {
return;
}
await clangdContext.dispose();
Expand Down
2 changes: 1 addition & 1 deletion test/inactive-regions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MockClangdContext implements ClangdContext {

async activate() { throw new Error('Method not implemented.'); }

clientIsReady() { return true; }
clientIsStarting() { return false; }

dispose() { throw new Error('Method not implemented.'); }
}
Expand Down

0 comments on commit 900eccb

Please sign in to comment.