Skip to content

Commit f9c5603

Browse files
committed
theia initial support
1 parent abfd788 commit f9c5603

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/extension.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,12 @@ async function serverManager(): Promise<any> {
325325
if (ignore) {
326326
return;
327327
}
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+
}
328334
await vscode.window
329335
.showInformationMessage(
330336
"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> {
335341
.then(async (action) => {
336342
switch (action) {
337343
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);
340345
await vscode.commands.executeCommand("workbench.extensions.installExtension", extId);
341346
extension = vscode.extensions.getExtension(extId);
342347
break;
@@ -362,9 +367,14 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
362367
}
363368

364369
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+
};
366376
extensionContext = context;
367-
workspaceState.update("workspaceFolder", "");
377+
workspaceState.update("workspaceFolder", undefined);
368378

369379
// Get api for servermanager extension, perhaps offering to install it
370380
serverManagerApi = await serverManager();
@@ -433,7 +443,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
433443
vscode.window.onDidChangeActiveTextEditor((textEditor: vscode.TextEditor) => {
434444
checkConnection();
435445
posPanel.text = "";
436-
if (textEditor.document.fileName.endsWith(".xml") && config("autoPreviewXML")) {
446+
if (textEditor?.document.fileName.endsWith(".xml") && config("autoPreviewXML")) {
437447
return xml2doc(context, textEditor);
438448
}
439449
});

0 commit comments

Comments
 (0)