diff --git a/src/vs/workbench/api/browser/mainThreadEditors.ts b/src/vs/workbench/api/browser/mainThreadEditors.ts index 68c31a3407a..441f6c68c70 100644 --- a/src/vs/workbench/api/browser/mainThreadEditors.ts +++ b/src/vs/workbench/api/browser/mainThreadEditors.ts @@ -302,7 +302,8 @@ CommandsRegistry.registerCommand('_workbench.open', async function (accessor: Se const editorGroupService = accessor.get(IEditorGroupsService); const openerService = accessor.get(IOpenerService); - const [resource, options, position, label] = args; + let [resource, options, position, label] = args; + resource = URI.revive(resource); if (options || typeof position === 'number') { // use editor options or editor view column as a hint to use the editor service for opening @@ -347,7 +348,7 @@ CommandsRegistry.registerCommand('_workbench.diff', async function (accessor: Se }; } - await editorService.openEditor({ leftResource, rightResource, label, description, options }, viewColumnToEditorGroup(editorGroupService, position)); + await editorService.openEditor({ leftResource: URI.revive(leftResource), rightResource: URI.revive(rightResource), label, description, options }, viewColumnToEditorGroup(editorGroupService, position)); }); CommandsRegistry.registerCommand('_workbench.revertAllDirty', async function (accessor: ServicesAccessor) { diff --git a/src/vs/workbench/api/common/extHostCommands.ts b/src/vs/workbench/api/common/extHostCommands.ts index c20a7a42ba7..666a97624f6 100644 --- a/src/vs/workbench/api/common/extHostCommands.ts +++ b/src/vs/workbench/api/common/extHostCommands.ts @@ -20,6 +20,7 @@ import { URI } from 'vs/base/common/uri'; import { DisposableStore, toDisposable } from 'vs/base/common/lifecycle'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService'; +import { DiffAPICommand, ICommandsExecutor, OpenAPICommand } from 'vs/workbench/api/common/apiCommands'; interface CommandHandler { callback: Function; @@ -217,6 +218,8 @@ export class ExtHostCommands implements ExtHostCommandsShape { export class CommandsConverter { + private readonly _commandConverter = new Map Promise>(); + private readonly _delegatingCommandId: string; private readonly _cache = new Map(); private _cachIdPool = 0; @@ -228,6 +231,9 @@ export class CommandsConverter { ) { this._delegatingCommandId = `_vscode_delegate_cmd_${Date.now().toString(36)}`; this._commands.registerCommand(true, this._delegatingCommandId, this._executeConvertedCommand, this); + + this._commandConverter.set(OpenAPICommand.ID, OpenAPICommand.execute); + this._commandConverter.set(DiffAPICommand.ID, DiffAPICommand.execute); } toInternal(command: vscode.Command, disposables: DisposableStore): ICommandDto; @@ -245,7 +251,19 @@ export class CommandsConverter { tooltip: command.tooltip }; - if (command.command && isNonEmptyArray(command.arguments)) { + const apiCommand = this._commandConverter.get(command.command); + if (apiCommand) { + // we have some API command registered for which we know how to convert + // them, e.g what internal ID they use and how to convert the arguments + apiCommand({ + async executeCommand(id, ...internalArgs: []) { + result.id = id; + result.arguments = internalArgs; + return undefined; + } + }, ...command.arguments ?? []); + + } else if (command.command && isNonEmptyArray(command.arguments)) { // we have a contributed command with arguments. that // means we don't want to send the arguments around