@@ -325,6 +325,12 @@ async function serverManager(): Promise<any> {
325
325
if ( ignore ) {
326
326
return ;
327
327
}
328
+ try {
329
+ await vscode . commands . executeCommand ( "extension.open" , extId ) ;
330
+ } catch ( ex ) {
331
+ // Such command do not exists, suppose we are under Theia, it's not possible to install this extension this way
332
+ return ;
333
+ }
328
334
await vscode . window
329
335
. showInformationMessage (
330
336
"The InterSystems® Server Manager extension is recommended to help you define connections and store passwords securely in your keychain." ,
@@ -335,8 +341,7 @@ async function serverManager(): Promise<any> {
335
341
. then ( async ( action ) => {
336
342
switch ( action ) {
337
343
case "Install" :
338
- await vscode . commands . executeCommand ( "workbench.extensions.search" , `@tag:"intersystems"` ) ;
339
- await vscode . commands . executeCommand ( "extension.open" , extId ) ;
344
+ await vscode . commands . executeCommand ( "workbench.extensions.search" , `@tag:"intersystems"` ) . then ( null , null ) ;
340
345
await vscode . commands . executeCommand ( "workbench.extensions.installExtension" , extId ) ;
341
346
extension = vscode . extensions . getExtension ( extId ) ;
342
347
break ;
@@ -362,9 +367,14 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
362
367
}
363
368
364
369
const languages = packageJson . contributes . languages . map ( ( lang ) => lang . id ) ;
365
- workspaceState = context . workspaceState ;
370
+ // workaround for Theia, issue https://github.com/eclipse-theia/theia/issues/8435
371
+ workspaceState = {
372
+ get : < T > ( key : string , defaultValue ?: T ) : T | undefined =>
373
+ context . workspaceState . get ( key , defaultValue ) || defaultValue ,
374
+ update : ( key : string , value : any ) : Thenable < void > => context . workspaceState . update ( key , value ) ,
375
+ } ;
366
376
extensionContext = context ;
367
- workspaceState . update ( "workspaceFolder" , "" ) ;
377
+ workspaceState . update ( "workspaceFolder" , undefined ) ;
368
378
369
379
// Get api for servermanager extension, perhaps offering to install it
370
380
serverManagerApi = await serverManager ( ) ;
@@ -433,7 +443,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
433
443
vscode . window . onDidChangeActiveTextEditor ( ( textEditor : vscode . TextEditor ) => {
434
444
checkConnection ( ) ;
435
445
posPanel . text = "" ;
436
- if ( textEditor . document . fileName . endsWith ( ".xml" ) && config ( "autoPreviewXML" ) ) {
446
+ if ( textEditor ? .document . fileName . endsWith ( ".xml" ) && config ( "autoPreviewXML" ) ) {
437
447
return xml2doc ( context , textEditor ) ;
438
448
}
439
449
} ) ;
0 commit comments