diff --git a/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts b/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts index a2adaf3bb6e..32b1b2c2de5 100644 --- a/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts +++ b/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.ts @@ -1644,7 +1644,7 @@ export class ModifiedElement extends AbstractElementRenderer { { updateInfoRendering: () => renderSourceEditor(), checkIfModified: (cell) => { - return cell.modified?.textModel.getValue() !== cell.original?.textModel.getValue() ? { reason: undefined } : false; + return cell.modified?.textModel.getTextBufferHash() !== cell.original?.textModel.getTextBufferHash() ? { reason: undefined } : false; }, getFoldingState: (cell) => cell.cellFoldingState, updateFoldingState: (cell, state) => cell.cellFoldingState = state, @@ -1660,7 +1660,7 @@ export class ModifiedElement extends AbstractElementRenderer { const scopedContextKeyService = this.contextKeyService.createScoped(this.templateData.inputToolbarContainer); this._register(scopedContextKeyService); const inputChanged = NOTEBOOK_DIFF_CELL_INPUT.bindTo(scopedContextKeyService); - inputChanged.set(this.cell.modified.textModel.getValue() !== this.cell.original.textModel.getValue()); + inputChanged.set(this.cell.modified.textModel.getTextBufferHash() !== this.cell.original.textModel.getTextBufferHash()); const ignoreWhitespace = NOTEBOOK_DIFF_CELL_IGNORE_WHITESPACE.bindTo(scopedContextKeyService); const ignore = this.textConfigurationService.getValue(this.cell.modified.uri, 'diffEditor.ignoreTrimWhitespace'); @@ -1675,7 +1675,7 @@ export class ModifiedElement extends AbstractElementRenderer { const refreshToolbar = () => { const ignore = this.textConfigurationService.getValue(this.cell.modified.uri, 'diffEditor.ignoreTrimWhitespace'); ignoreWhitespace.set(ignore); - const hasChanges = this.cell.modified.textModel.getValue() !== this.cell.original.textModel.getValue(); + const hasChanges = this.cell.modified.textModel.getTextBufferHash() !== this.cell.original.textModel.getTextBufferHash(); inputChanged.set(hasChanges); if (hasChanges) { diff --git a/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.ts b/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.ts index 0c82062b13c..788d742adef 100644 --- a/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffViewModel.ts @@ -443,7 +443,7 @@ function createDiffViewModels(instantiationService: IInstantiationService, confi case 'unchanged': { const originalCell = originalModel.cells[diff.originalCellIndex]; const modifiedCell = modifiedModel.cells[diff.modifiedCellIndex]; - const type = (originalCell.textModel?.getValue() !== modifiedCell.textModel?.getValue()) ? 'modified' : 'unchanged'; + const type = originalCell.equal(modifiedCell) ? 'unchanged' : 'modified'; return new SideBySideDiffElementViewModel( model.modified.notebook, model.original.notebook, diff --git a/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts b/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts index 3d7310c6438..e83261cf204 100644 --- a/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts +++ b/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.ts @@ -419,6 +419,10 @@ export class NotebookCellTextModel extends Disposable implements ICell { return false; } + if (this.outputs.length !== b.outputs.length) { + return false; + } + if (this.getTextLength() !== b.getTextLength()) { return false; }