Skip to content

Commit

Permalink
Make sure we delay start pylance server (#20910)
Browse files Browse the repository at this point in the history
fixes #20909

Activating `pylance` extension inside of `python` extension cause a dead
lock since they have circular dependency. now we make sure we activate
`pylance` once `python` extension is activated.

`node` already works this way. it is just browser extension that started
`pylance` inside `activate` directly.
  • Loading branch information
heejaechang authored Mar 24, 2023
1 parent be55c97 commit 5f9be4e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/client/browser/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ interface BrowserConfig {
let languageClient: LanguageClient | undefined;
let pylanceApi: PylanceApi | undefined;

export async function activate(context: vscode.ExtensionContext): Promise<IBrowserExtensionApi> {
export function activate(context: vscode.ExtensionContext): Promise<IBrowserExtensionApi> {
const reporter = getTelemetryReporter();

const activationPromise = Promise.resolve(buildApi(reporter));
const pylanceExtension = vscode.extensions.getExtension<PylanceApi>(PYLANCE_EXTENSION_ID);
if (pylanceExtension) {
await runPylance(context, pylanceExtension);
return buildApi(reporter);
// Make sure we run pylance once we activated core extension.
activationPromise.then(() => runPylance(context, pylanceExtension));
return activationPromise;
}

const changeDisposable = vscode.extensions.onDidChange(async () => {
Expand All @@ -37,7 +39,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<IBrows
}
});

return buildApi(reporter);
return activationPromise;
}

export async function deactivate(): Promise<void> {
Expand Down

0 comments on commit 5f9be4e

Please sign in to comment.