Skip to content

Commit

Permalink
Introduce text multi diff (#207747)
Browse files Browse the repository at this point in the history
  • Loading branch information
lramos15 authored Mar 14, 2024
1 parent 6269ab4 commit 98968c0
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 5 deletions.
21 changes: 20 additions & 1 deletion src/vs/workbench/api/browser/mainThreadEditorTabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { DisposableStore } from 'vs/base/common/lifecycle';
import { ExtHostContext, IExtHostEditorTabsShape, MainContext, IEditorTabDto, IEditorTabGroupDto, MainThreadEditorTabsShape, AnyInputDto, TabInputKind, TabModelOperationKind } from 'vs/workbench/api/common/extHost.protocol';
import { ExtHostContext, IExtHostEditorTabsShape, MainContext, IEditorTabDto, IEditorTabGroupDto, MainThreadEditorTabsShape, AnyInputDto, TabInputKind, TabModelOperationKind, TextDiffInputDto } from 'vs/workbench/api/common/extHost.protocol';
import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers';
import { EditorResourceAccessor, GroupModelChangeKind, SideBySideEditor } from 'vs/workbench/common/editor';
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
Expand All @@ -26,6 +26,7 @@ import { InteractiveEditorInput } from 'vs/workbench/contrib/interactive/browser
import { MergeEditorInput } from 'vs/workbench/contrib/mergeEditor/browser/mergeEditorInput';
import { ILogService } from 'vs/platform/log/common/log';
import { ChatEditorInput } from 'vs/workbench/contrib/chat/browser/chatEditorInput';
import { MultiDiffEditorInput } from 'vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput';

interface TabInfo {
tab: IEditorTabDto;
Expand Down Expand Up @@ -199,6 +200,24 @@ export class MainThreadEditorTabs implements MainThreadEditorTabsShape {
};
}

if (editor instanceof MultiDiffEditorInput) {
const diffEditors: TextDiffInputDto[] = [];
for (const resource of (editor?.initialResources ?? [])) {
if (resource.original && resource.modified) {
diffEditors.push({
kind: TabInputKind.TextDiffInput,
original: resource.original,
modified: resource.modified
});
}
}

return {
kind: TabInputKind.MultiDiffEditorInput,
diffEditors
};
}

return { kind: TabInputKind.UnknownInput };
}

Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
TabInputTerminal: extHostTypes.TerminalEditorTabInput,
TabInputInteractiveWindow: extHostTypes.InteractiveWindowInput,
TabInputChat: extHostTypes.ChatEditorTabInput,
TabInputTextMultiDiff: extHostTypes.TextMultiDiffTabInput,
TelemetryTrustedValue: TelemetryTrustedValue,
LogLevel: LogLevel,
EditSessionIdentityMatch: EditSessionIdentityMatch,
Expand Down
10 changes: 8 additions & 2 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,8 @@ export const enum TabInputKind {
WebviewEditorInput,
TerminalEditorInput,
InteractiveEditorInput,
ChatEditorInput
ChatEditorInput,
MultiDiffEditorInput
}

export const enum TabModelOperationKind {
Expand Down Expand Up @@ -767,11 +768,16 @@ export interface ChatEditorInputDto {
providerId: string;
}

export interface MultiDiffEditorInputDto {
kind: TabInputKind.MultiDiffEditorInput;
diffEditors: TextDiffInputDto[];
}

export interface TabInputDto {
kind: TabInputKind.TerminalEditorInput;
}

export type AnyInputDto = UnknownInputDto | TextInputDto | TextDiffInputDto | TextMergeInputDto | NotebookInputDto | NotebookDiffInputDto | CustomInputDto | WebviewInputDto | InteractiveEditorInputDto | ChatEditorInputDto | TabInputDto;
export type AnyInputDto = UnknownInputDto | TextInputDto | TextDiffInputDto | MultiDiffEditorInputDto | TextMergeInputDto | NotebookInputDto | NotebookDiffInputDto | CustomInputDto | WebviewInputDto | InteractiveEditorInputDto | ChatEditorInputDto | TabInputDto;

export interface MainThreadEditorTabsShape extends IDisposable {
// manage tabs: move, close, rearrange etc
Expand Down
6 changes: 4 additions & 2 deletions src/vs/workbench/api/common/extHostEditorTabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
import { IEditorTabDto, IEditorTabGroupDto, IExtHostEditorTabsShape, MainContext, MainThreadEditorTabsShape, TabInputKind, TabModelOperationKind, TabOperation } from 'vs/workbench/api/common/extHost.protocol';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import * as typeConverters from 'vs/workbench/api/common/extHostTypeConverters';
import { ChatEditorTabInput, CustomEditorTabInput, InteractiveWindowInput, NotebookDiffEditorTabInput, NotebookEditorTabInput, TerminalEditorTabInput, TextDiffTabInput, TextMergeTabInput, TextTabInput, WebviewEditorTabInput } from 'vs/workbench/api/common/extHostTypes';
import { ChatEditorTabInput, CustomEditorTabInput, InteractiveWindowInput, NotebookDiffEditorTabInput, NotebookEditorTabInput, TerminalEditorTabInput, TextDiffTabInput, TextMergeTabInput, TextTabInput, WebviewEditorTabInput, TextMultiDiffTabInput } from 'vs/workbench/api/common/extHostTypes';
import type * as vscode from 'vscode';

export interface IExtHostEditorTabs extends IExtHostEditorTabsShape {
Expand All @@ -21,7 +21,7 @@ export interface IExtHostEditorTabs extends IExtHostEditorTabsShape {

export const IExtHostEditorTabs = createDecorator<IExtHostEditorTabs>('IExtHostEditorTabs');

type AnyTabInput = TextTabInput | TextDiffTabInput | CustomEditorTabInput | NotebookEditorTabInput | NotebookDiffEditorTabInput | WebviewEditorTabInput | TerminalEditorTabInput | InteractiveWindowInput | ChatEditorTabInput;
type AnyTabInput = TextTabInput | TextDiffTabInput | TextMultiDiffTabInput | CustomEditorTabInput | NotebookEditorTabInput | NotebookDiffEditorTabInput | WebviewEditorTabInput | TerminalEditorTabInput | InteractiveWindowInput | ChatEditorTabInput;

class ExtHostEditorTab {
private _apiObject: vscode.Tab | undefined;
Expand Down Expand Up @@ -100,6 +100,8 @@ class ExtHostEditorTab {
return new InteractiveWindowInput(URI.revive(this._dto.input.uri), URI.revive(this._dto.input.inputBoxUri));
case TabInputKind.ChatEditorInput:
return new ChatEditorTabInput(this._dto.input.providerId);
case TabInputKind.MultiDiffEditorInput:
return new TextMultiDiffTabInput(this._dto.input.diffEditors.map(diff => new TextDiffTabInput(URI.revive(diff.original), URI.revive(diff.modified))));
default:
return undefined;
}
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4204,6 +4204,10 @@ export class InteractiveWindowInput {
export class ChatEditorTabInput {
constructor(readonly providerId: string) { }
}

export class TextMultiDiffTabInput {
constructor(readonly textDiffs: TextDiffTabInput[]) { }
}
//#endregion

//#region Chat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const allApiProposals = Object.freeze({
shareProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.shareProvider.d.ts',
showLocal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.showLocal.d.ts',
speech: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.speech.d.ts',
tabInputMultiDiff: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.tabInputMultiDiff.d.ts',
tabInputTextMerge: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.tabInputTextMerge.d.ts',
taskPresentationGroup: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.taskPresentationGroup.d.ts',
telemetry: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.telemetry.d.ts',
Expand Down
22 changes: 22 additions & 0 deletions src/vscode-dts/vscode.proposed.tabInputMultiDiff.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

// https://github.com/microsoft/vscode/issues/206411

declare module 'vscode' {

export class TabInputTextMultiDiff {

readonly textDiffs: TabInputTextDiff[];

constructor(textDiffs: TabInputTextDiff[]);
}

export interface Tab {

readonly input: TabInputText | TabInputTextDiff | TabInputTextMultiDiff | TabInputCustom | TabInputWebview | TabInputNotebook | TabInputNotebookDiff | TabInputTerminal | unknown;

}
}

0 comments on commit 98968c0

Please sign in to comment.