Skip to content

Commit f884804

Browse files
authored
Ensure cell Id is the only part of internal metadata used in diffing (microsoft#242382)
* Ensure cell Id is the only part of internal metadata used in diffing * misc * misc * Add comments * wip * Misc
1 parent 0480008 commit f884804

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,6 @@ export class NotebookCellTextModel extends Disposable implements ICell {
209209
this._outputs = outputs.map(op => new NotebookCellOutputTextModel(op));
210210
this._metadata = metadata ?? {};
211211
this._internalMetadata = internalMetadata ?? {};
212-
this._internalMetadata.cellId = this._internalMetadata.cellId ??
213-
this._metadata.id as string ??
214-
uri.fragment;
215212
}
216213

217214
enableAutoLanguageDetection() {

src/vs/workbench/contrib/notebook/common/notebookCommon.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ export interface NotebookCellMetadata {
121121
}
122122

123123
export interface NotebookCellInternalMetadata {
124+
/**
125+
* Used only for diffing of Notebooks.
126+
* This is not persisted and generally useful only when diffing two notebooks.
127+
* Useful only after we've manually matched a few cells together so we know which cells are matching.
128+
*/
124129
cellId?: string;
125130
executionId?: string;
126131
executionOrder?: number;

src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class MirrorCell {
5656
hashValue = doHash(this.language, hashValue);
5757
hashValue = doHash(this.getValue(), hashValue);
5858
hashValue = doHash(this.metadata, hashValue);
59-
hashValue = doHash({ ...this.internalMetadata, 'cellId': '' }, hashValue);
59+
// For purpose of diffing only cellId matters, rest do not
60+
hashValue = doHash(this.internalMetadata?.cellId || '', hashValue);
6061
for (const op of this.outputs) {
6162
hashValue = doHash(op.metadata, hashValue);
6263
for (const output of op.outputs) {

0 commit comments

Comments
 (0)