Skip to content

Commit 14f21ac

Browse files
committed
Adds title property to command.
Renames 3wm editor default titles to input1/input2.
1 parent dd2ca4c commit 14f21ac

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

src/vs/workbench/contrib/mergeEditor/browser/commands/commands.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,21 @@ namespace IRelaxedOpenArgs {
5858

5959
function toInputResource(obj: unknown): MergeEditorInputData {
6060
if (typeof obj === 'string') {
61-
return new MergeEditorInputData(URI.parse(obj, true), undefined, undefined);
61+
return new MergeEditorInputData(URI.parse(obj, true), undefined, undefined, undefined);
6262
}
6363
if (!obj || typeof obj !== 'object') {
6464
throw new TypeError('invalid argument');
6565
}
6666

6767
if (isUriComponents(obj)) {
68-
return new MergeEditorInputData(URI.revive(obj), undefined, undefined);
68+
return new MergeEditorInputData(URI.revive(obj), undefined, undefined, undefined);
6969
}
7070

71+
const title = (<IRelaxedInputData>obj).title;
7172
const uri = toUri((<IRelaxedInputData>obj).uri);
7273
const detail = (<IRelaxedInputData>obj).detail;
7374
const description = (<IRelaxedInputData>obj).description;
74-
return new MergeEditorInputData(uri, detail, description);
75+
return new MergeEditorInputData(uri, title, detail, description);
7576
}
7677

7778
export function validate(obj: unknown): IOpenEditorArgs {
@@ -86,7 +87,7 @@ namespace IRelaxedOpenArgs {
8687
}
8788
}
8889

89-
type IRelaxedInputData = { uri: UriComponents; detail?: string; description?: string };
90+
type IRelaxedInputData = { uri: UriComponents; title?: string; detail?: string; description?: string };
9091

9192
type IRelaxedOpenArgs = {
9293
ancestor: UriComponents | string;

src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ export class MergeEditorOpenContents extends Action2 {
139139
const input = instaService.createInstance(
140140
MergeEditorInput,
141141
baseUri,
142-
{ uri: input1Uri, description: 'Input 1', detail: '(from JSON)' },
143-
{ uri: input2Uri, description: 'Input 2', detail: '(from JSON)' },
142+
{ uri: input1Uri, title: 'Input 1', description: 'Input 1', detail: '(from JSON)' },
143+
{ uri: input2Uri, title: 'Input 2', description: 'Input 2', detail: '(from JSON)' },
144144
resultUri,
145145
);
146146
editorService.openEditor(input);

src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ import { ITextFileEditorModel, ITextFileService } from 'vs/workbench/services/te
2020

2121
export interface MergeEditorInputJSON {
2222
anchestor: URI;
23-
inputOne: { uri: URI; detail?: string; description?: string };
24-
inputTwo: { uri: URI; detail?: string; description?: string };
23+
inputOne: { uri: URI; title?: string; detail?: string; description?: string };
24+
inputTwo: { uri: URI; title?: string; detail?: string; description?: string };
2525
result: URI;
2626
}
2727

2828
export class MergeEditorInputData {
2929
constructor(
3030
readonly uri: URI,
31+
readonly title: string | undefined,
3132
readonly detail: string | undefined,
3233
readonly description: string | undefined,
3334
) { }
@@ -109,9 +110,11 @@ export class MergeEditorInput extends AbstractTextResourceEditorInput {
109110
MergeEditorModel,
110111
base.object.textEditorModel,
111112
input1.object.textEditorModel,
113+
this._input1.title,
112114
this._input1.detail,
113115
this._input1.description,
114116
input2.object.textEditorModel,
117+
this._input2.title,
115118
this._input2.detail,
116119
this._input2.description,
117120
result.object.textEditorModel

src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class MergeEditorSerializer implements IEditorSerializer {
2525
return instantiationService.createInstance(
2626
MergeEditorInput,
2727
data.anchestor,
28-
new MergeEditorInputData(data.inputOne.uri, data.inputOne.detail, data.inputOne.description),
29-
new MergeEditorInputData(data.inputTwo.uri, data.inputTwo.detail, data.inputTwo.description),
28+
new MergeEditorInputData(data.inputOne.uri, data.inputOne.title, data.inputOne.detail, data.inputOne.description),
29+
new MergeEditorInputData(data.inputTwo.uri, data.inputTwo.title, data.inputTwo.detail, data.inputTwo.description),
3030
data.result
3131
);
3232
} catch (err) {

src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,11 @@ export class MergeEditorModel extends EditorModel {
126126
constructor(
127127
readonly base: ITextModel,
128128
readonly input1: ITextModel,
129+
readonly input1Title: string | undefined,
129130
readonly input1Detail: string | undefined,
130131
readonly input1Description: string | undefined,
131132
readonly input2: ITextModel,
133+
readonly input2Title: string | undefined,
132134
readonly input2Detail: string | undefined,
133135
readonly input2Description: string | undefined,
134136
readonly result: ITextModel,

src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ export class MergeEditor extends AbstractTextEditor<any> {
230230

231231
const viewModel = new MergeEditorViewModel(model, this.input1View, this.input2View, this.inputResultView);
232232

233-
this.input1View.setModel(viewModel, model.input1, localize('yours', 'Yours'), model.input1Detail, model.input1Description);
234-
this.input2View.setModel(viewModel, model.input2, localize('theirs', 'Theirs',), model.input2Detail, model.input2Description);
233+
this.input1View.setModel(viewModel, model.input1, model.input1Title || localize('input1', 'Input 1'), model.input1Detail, model.input1Description);
234+
this.input2View.setModel(viewModel, model.input2, model.input2Title || localize('input2', 'Input 2',), model.input2Detail, model.input2Description);
235235
this.inputResultView.setModel(viewModel, model.result, localize('result', 'Result',), this._labelService.getUriLabel(model.result.uri, { relative: true }), undefined);
236236
this._ctxBaseResourceScheme.set(model.base.uri.scheme);
237237

0 commit comments

Comments
 (0)