Skip to content

Commit 1f3bd32

Browse files
committed
adding option to serialize
1 parent 2110f10 commit 1f3bd32

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

src/vs/workbench/browser/parts/editor/editorsObserver.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,19 +430,24 @@ export class EditorsObserver extends Disposable {
430430
entries: coalesce(entries.map(({ editor, groupId }) => {
431431

432432
// Find group for entry
433+
console.log('editor: ', editor);
434+
console.log('groupId : ', groupId);
433435
const group = this.editorGroupsContainer.getGroup(groupId);
436+
console.log('group : ', group);
434437
if (!group) {
435438
return undefined;
436439
}
437440

438441
// Find serializable editors of group
439442
let serializableEditorsOfGroup = mapGroupToSerializableEditorsOfGroup.get(group);
443+
console.log('serializableEditorsOfGroup : ', serializableEditorsOfGroup);
440444
if (!serializableEditorsOfGroup) {
441445
serializableEditorsOfGroup = group.getEditors(EditorsOrder.SEQUENTIAL).filter(editor => {
442446
const editorSerializer = registry.getEditorSerializer(editor);
443447

444448
return editorSerializer?.canSerialize(editor);
445449
});
450+
console.log('serializableEditorsOfGroup : ', serializableEditorsOfGroup);
446451
mapGroupToSerializableEditorsOfGroup.set(group, serializableEditorsOfGroup);
447452
}
448453

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/common/editor/editorGroupModel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,9 +1032,10 @@ export class EditorGroupModel extends Disposable implements IEditorGroupModel {
10321032
let canSerializeEditor = false;
10331033

10341034
const editorSerializer = registry.getEditorSerializer(editor);
1035-
if (editorSerializer) {
1035+
if (editorSerializer && editorSerializer.canSerialize(editor)) {
10361036
const value = editorSerializer.serialize(editor);
10371037

1038+
console.log('value : ', value);
10381039
// Editor can be serialized
10391040
if (typeof value === 'string') {
10401041
canSerializeEditor = true;

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: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,21 @@ export class MultiDiffEditorInput extends EditorInput implements ILanguageSuppor
4848
resource.modified.resource,
4949
);
5050
}),
51+
input.isTransient ?? false
5152
);
5253
}
5354

5455
public static fromSerialized(data: ISerializedMultiDiffEditorInput, instantiationService: IInstantiationService): MultiDiffEditorInput {
56+
console.log('inside of fromSerialized');
5557
return instantiationService.createInstance(
5658
MultiDiffEditorInput,
5759
URI.parse(data.multiDiffSourceUri),
5860
data.label,
5961
data.resources?.map(resource => new MultiDiffEditorItem(
6062
resource.originalUri ? URI.parse(resource.originalUri) : undefined,
6163
resource.modifiedUri ? URI.parse(resource.modifiedUri) : undefined,
62-
))
64+
)),
65+
false
6366
);
6467
}
6568

@@ -80,12 +83,14 @@ export class MultiDiffEditorInput extends EditorInput implements ILanguageSuppor
8083
public readonly multiDiffSource: URI,
8184
public readonly label: string | undefined,
8285
public readonly initialResources: readonly MultiDiffEditorItem[] | undefined,
86+
public readonly isTransient: boolean = false,
8387
@ITextModelService private readonly _textModelService: ITextModelService,
8488
@ITextResourceConfigurationService private readonly _textResourceConfigurationService: ITextResourceConfigurationService,
8589
@IInstantiationService private readonly _instantiationService: IInstantiationService,
8690
@IMultiDiffSourceResolverService private readonly _multiDiffSourceResolverService: IMultiDiffSourceResolverService,
8791
@ITextFileService private readonly _textFileService: ITextFileService,
8892
) {
93+
console.log('isTransient from the constructor : ', isTransient);
8994
super();
9095

9196
this._register(autorun((reader) => {
@@ -361,14 +366,18 @@ interface ISerializedMultiDiffEditorInput {
361366

362367
export class MultiDiffEditorSerializer implements IEditorSerializer {
363368
canSerialize(editor: EditorInput): boolean {
364-
return editor instanceof MultiDiffEditorInput;
369+
console.log('inside of can serialize');
370+
console.log('editor instanceof MultiDiffEditorInput && !editor.isTransient : ', editor instanceof MultiDiffEditorInput && !editor.isTransient);
371+
return editor instanceof MultiDiffEditorInput && !editor.isTransient;
365372
}
366373

367374
serialize(editor: MultiDiffEditorInput): string | undefined {
375+
console.log('inside of serialize');
368376
return JSON.stringify(editor.serialize());
369377
}
370378

371379
deserialize(instantiationService: IInstantiationService, serializedEditor: string): EditorInput | undefined {
380+
console.log('inside of deserialize');
372381
try {
373382
const data = parse(serializedEditor) as ISerializedMultiDiffEditorInput;
374383
return MultiDiffEditorInput.fromSerialized(data, instantiationService);

0 commit comments

Comments
 (0)