src/vs/workbench/browser/parts/editor/editorCommands.ts/mixinContext
function registerOpenEditorAPICommands(): void {

	function mixinContext(context: IOpenEvent<unknown> | undefined, options: ITextEditorOptions | undefined, column: EditorGroupColumn | undefined): [ITextEditorOptions | undefined, EditorGroupColumn | undefined] {
		if (!context) {
			return [options, column];
		}

		return [
			{ ...context.editorOptions, ...(options ?? Object.create(null)) },
			context.sideBySide ? SIDE_GROUP : column
		];
	}

	CommandsRegistry.registerCommand(API_OPEN_EDITOR_COMMAND_ID, async function (accessor: ServicesAccessor, resourceArg: UriComponents, columnAndOptions?: [EditorGroupColumn?, ITextEditorOptions?], label?: string, context?: IOpenEvent<unknown>) {
		const editorService = accessor.get(IEditorService);
		const editorGroupService = accessor.get(IEditorGroupsService);
		const openerService = accessor.get(IOpenerService);

		const resource = URI.revive(resourceArg);
		const [columnArg, optionsArg] = columnAndOptions ?? [];

		// use editor options or editor view column as a hint to use the editor service for opening
		if (optionsArg || typeof columnArg === 'number') {
			const [options, column] = mixinContext(context, optionsArg, columnArg);

			await editorService.openEditor({ resource, options, label }, viewColumnToEditorGroup(editorGroupService, column));
		}

		// do not allow to execute commands from here
		else if (resource.scheme === 'command') {
			return;
		}

		// finally, delegate to opener service
		else {
			await openerService.open(resource, { openToSide: context?.sideBySide, editorOptions: context?.editorOptions });
		}
	});

	CommandsRegistry.registerCommand(API_OPEN_DIFF_EDITOR_COMMAND_ID, async function (accessor: ServicesAccessor, originalResource: UriComponents, modifiedResource: UriComponents, label?: string, columnAndOptions?: [EditorGroupColumn?, ITextEditorOptions?], context?: IOpenEvent<unknown>) {
		const editorService = accessor.get(IEditorService);
		const editorGroupService = accessor.get(IEditorGroupsService);

		const [columnArg, optionsArg] = columnAndOptions ?? [];
		const [options, column] = mixinContext(context, optionsArg, columnArg);

		await editorService.openEditor({
			originalInput: { resource: URI.revive(originalResource) },
			modifiedInput: { resource: URI.revive(modifiedResource) },
			label,
			options
		}, viewColumnToEditorGroup(editorGroupService, column));
	});

	CommandsRegistry.registerCommand(API_OPEN_WITH_EDITOR_COMMAND_ID, (accessor: ServicesAccessor, resource: UriComponents, id: string, columnAndOptions?: [EditorGroupColumn?, ITextEditorOptions?]) => {
		const editorService = accessor.get(IEditorService);
		const editorGroupsService = accessor.get(IEditorGroupsService);
		const configurationService = accessor.get(IConfigurationService);

		const [columnArg, optionsArg] = columnAndOptions ?? [];
		let group: IEditorGroup | undefined = undefined;

		if (columnArg === SIDE_GROUP) {
			const direction = preferredSideBySideGroupDirection(configurationService);

			let neighbourGroup = editorGroupsService.findGroup({ direction });
			if (!neighbourGroup) {
				neighbourGroup = editorGroupsService.addGroup(editorGroupsService.activeGroup, direction);
			}
			group = neighbourGroup;
		} else {
			group = editorGroupsService.getGroup(viewColumnToEditorGroup(editorGroupsService, columnArg)) ?? editorGroupsService.activeGroup;
		}

		return editorService.openEditor({ resource: URI.revive(resource), options: { ...optionsArg, pinned: true, override: id } }, group);
	});
}