File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -17,13 +17,28 @@ interface BrowserConfig {
17
17
18
18
export async function activate ( context : vscode . ExtensionContext ) : Promise < void > {
19
19
// Run in a promise and return early so that VS Code can go activate Pylance.
20
- runPylance ( context ) ;
21
- }
22
20
23
- async function runPylance ( context : vscode . ExtensionContext ) : Promise < void > {
24
21
const pylanceExtension = vscode . extensions . getExtension < ILSExtensionApi > ( PYLANCE_EXTENSION_ID ) ;
25
- const pylanceApi = await pylanceExtension ?. activate ( ) ;
26
- if ( ! pylanceApi ?. languageServerFolder ) {
22
+ if ( pylanceExtension ) {
23
+ runPylance ( context , pylanceExtension ) ;
24
+ return ;
25
+ }
26
+
27
+ const changeDisposable = vscode . extensions . onDidChange ( ( ) => {
28
+ const newPylanceExtension = vscode . extensions . getExtension < ILSExtensionApi > ( PYLANCE_EXTENSION_ID ) ;
29
+ if ( newPylanceExtension ) {
30
+ changeDisposable . dispose ( ) ;
31
+ runPylance ( context , newPylanceExtension ) ;
32
+ }
33
+ } ) ;
34
+ }
35
+
36
+ async function runPylance (
37
+ context : vscode . ExtensionContext ,
38
+ pylanceExtension : vscode . Extension < ILSExtensionApi > ,
39
+ ) : Promise < void > {
40
+ const pylanceApi = await pylanceExtension . activate ( ) ;
41
+ if ( ! pylanceApi . languageServerFolder ) {
27
42
throw new Error ( 'Could not find Pylance extension' ) ;
28
43
}
29
44
You can’t perform that action at this time.
0 commit comments