Skip to content

Commit d41ee13

Browse files
authored
Merge pull request microsoft#205706 from microsoft/aiday/addingOptionToSerialize
Adding `isTransient` boolean to the multi diff editor input
2 parents ee69e28 + 0235977 commit d41ee13

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/vs/workbench/common/editor.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,11 @@ export interface IResourceMultiDiffEditorInput extends IBaseUntypedEditorInput {
505505
* If not set, the resources are dynamically derived from the {@link multiDiffSource}.
506506
*/
507507
readonly resources?: IResourceDiffEditorInput[];
508+
509+
/**
510+
* Whether the editor should be serialized and stored for subsequent sessions.
511+
*/
512+
readonly isTransient?: boolean;
508513
}
509514

510515
export type IResourceMergeEditorInputSide = (IResourceEditorInput | ITextResourceEditorInput) & { detail?: string };

src/vs/workbench/contrib/bulkEdit/browser/preview/bulkEditPane.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ export class BulkEditPane extends ViewPane {
351351
resources,
352352
label,
353353
options,
354+
isTransient: true,
354355
description: label
355356
}, e.sideBySide ? SIDE_GROUP : ACTIVE_GROUP);
356357
}

src/vs/workbench/contrib/multiDiffEditor/browser/multiDiffEditorInput.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class MultiDiffEditorInput extends EditorInput implements ILanguageSuppor
4848
resource.modified.resource,
4949
);
5050
}),
51+
input.isTransient ?? false
5152
);
5253
}
5354

@@ -59,7 +60,8 @@ export class MultiDiffEditorInput extends EditorInput implements ILanguageSuppor
5960
data.resources?.map(resource => new MultiDiffEditorItem(
6061
resource.originalUri ? URI.parse(resource.originalUri) : undefined,
6162
resource.modifiedUri ? URI.parse(resource.modifiedUri) : undefined,
62-
))
63+
)),
64+
false
6365
);
6466
}
6567

@@ -80,6 +82,7 @@ export class MultiDiffEditorInput extends EditorInput implements ILanguageSuppor
8082
public readonly multiDiffSource: URI,
8183
public readonly label: string | undefined,
8284
public readonly initialResources: readonly MultiDiffEditorItem[] | undefined,
85+
public readonly isTransient: boolean = false,
8386
@ITextModelService private readonly _textModelService: ITextModelService,
8487
@ITextResourceConfigurationService private readonly _textResourceConfigurationService: ITextResourceConfigurationService,
8588
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@@ -360,12 +363,15 @@ interface ISerializedMultiDiffEditorInput {
360363
}
361364

362365
export class MultiDiffEditorSerializer implements IEditorSerializer {
366+
367+
// TODO@bpasero, @aiday-mar: following canSerialize should be removed (debt item)
363368
canSerialize(editor: EditorInput): boolean {
364-
return editor instanceof MultiDiffEditorInput;
369+
return editor instanceof MultiDiffEditorInput && !editor.isTransient;
365370
}
366371

367372
serialize(editor: MultiDiffEditorInput): string | undefined {
368-
return JSON.stringify(editor.serialize());
373+
const shouldSerialize = editor instanceof MultiDiffEditorInput && !editor.isTransient;
374+
return shouldSerialize ? JSON.stringify(editor.serialize()) : undefined;
369375
}
370376

371377
deserialize(instantiationService: IInstantiationService, serializedEditor: string): EditorInput | undefined {

0 commit comments

Comments
 (0)