Add 'vscode.reopenWith' API command

Fixes #88426

Add an api command that allows extensions to open/reopen a file with a specific we custom editor. Use this to allow re-opening a failed to load image as text/binary

For #77131
This commit is contained in:
Matt Bierner
2020-01-10 14:24:50 -08:00
parent 5c71a0b18b
commit a0328d26ac
5 changed files with 46 additions and 35 deletions

View File

@@ -132,6 +132,24 @@ export class OpenAPICommand {
}
CommandsRegistry.registerCommand(OpenAPICommand.ID, adjustHandler(OpenAPICommand.execute));
export class OpenWithAPICommand {
public static readonly ID = 'vscode.openWith';
public static execute(executor: ICommandsExecutor, resource: URI, viewType: string, column?: vscode.ViewColumn): Promise<any> {
let position: EditorViewColumn | undefined;
if (typeof column === 'number') {
position = typeConverters.ViewColumn.from(column);
}
return executor.executeCommand('_workbench.openWith', [
resource,
viewType,
position
]);
}
}
CommandsRegistry.registerCommand(OpenWithAPICommand.ID, adjustHandler(OpenWithAPICommand.execute));
CommandsRegistry.registerCommand('_workbench.removeFromRecentlyOpened', function (accessor: ServicesAccessor, uri: URI) {
const workspacesService = accessor.get(IWorkspacesService);
return workspacesService.removeFromRecentlyOpened([uri]);