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 {
1717
1818export  async  function  activate ( context : vscode . ExtensionContext ) : Promise < void >  { 
1919 // Run in a promise and return early so that VS Code can go activate Pylance. 
20-  runPylance ( context ) ; 
21- } 
2220
23- async  function  runPylance ( context : vscode . ExtensionContext ) : Promise < void >  { 
2421 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 )  { 
2742 throw  new  Error ( 'Could not find Pylance extension' ) ; 
2843 } 
2944
                         You can’t perform that action at this time. 
           
                  
0 commit comments