Skip to content

Commit

Permalink
Part 2
Browse files Browse the repository at this point in the history
Implementing similar to vscode
  • Loading branch information
FernandoAscencio committed Mar 7, 2023
1 parent ab5d7c9 commit 27a169d
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,21 @@ export class PluginVscodeCommandsContribution implements CommandContribution {
isVisible: () => false,
execute: async (resource: URI, columnOrOptions?: ViewColumn | TextDocumentShowOptions) => {
try {
const result = await this.openWith(VscodeCommands.OPEN.id, resource, columnOrOptions);
if (!result) {
throw new Error(`Could not find an editor for ${resource}`);
}
await this.openWith(VscodeCommands.OPEN.id, resource, columnOrOptions);
} catch (error) {
this.messageService.error(nls.localizeByDefault("Unable to open '{0}'", resource.path.toString()));
console.log(error.stack ? error.stack : error.toString());
const message = nls.localizeByDefault("Unable to open '{0}'", resource.fsPath);
const createFile = 'Create File';
this.messageService.error(message, createFile).then(async action => {
if (action === createFile) {
try {
await this.fileService.create(new TheiaURI(resource));
await this.openWith(VscodeCommands.OPEN.id, resource, columnOrOptions);
} catch (e) {
this.messageService.error(e.message);
console.log(e.stack ? e.stack : e.toString());
}
}
});
}
}
});
Expand Down

0 comments on commit 27a169d

Please sign in to comment.