From 79e1ebbb7f4a31cb1b0bea645448575f611661cb Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 15 Sep 2020 10:22:12 +0200 Subject: [PATCH] add check no-op changes, https://github.com/microsoft/vscode/issues/105283 --- src/vs/workbench/api/common/extHostNotebookEditor.ts | 3 +++ src/vs/workbench/api/common/extHostTypes.ts | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/api/common/extHostNotebookEditor.ts b/src/vs/workbench/api/common/extHostNotebookEditor.ts index 414ff8fea27..67fcc4f17d8 100644 --- a/src/vs/workbench/api/common/extHostNotebookEditor.ts +++ b/src/vs/workbench/api/common/extHostNotebookEditor.ts @@ -65,6 +65,9 @@ class NotebookEditorCellEditBuilder implements vscode.NotebookEditorEdit { replaceCells(from: number, to: number, cells: vscode.NotebookCellData[]): void { this._throwIfFinalized(); + if (from === to && cells.length === 0) { + return; + } this._collectedEdits.push({ editType: CellEditType.Replace, index: from, diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index dcd13550203..8f4b93a8ac1 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -637,7 +637,9 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit { } replaceNotebookCells(uri: URI, start: number, end: number, cells: vscode.NotebookCellData[], metadata?: vscode.WorkspaceEditEntryMetadata): void { - this._edits.push({ _type: FileEditType.Cell, metadata, uri, edit: { editType: CellEditType.Replace, index: start, count: end - start, cells: cells.map(cell => ({ ...cell, outputs: cell.outputs.map(output => addIdToOutput(output)) })) } }); + if (start !== end || cells.length > 0) { + this._edits.push({ _type: FileEditType.Cell, metadata, uri, edit: { editType: CellEditType.Replace, index: start, count: end - start, cells: cells.map(cell => ({ ...cell, outputs: cell.outputs.map(output => addIdToOutput(output)) })) } }); + } } replaceNotebookCellOutput(uri: URI, index: number, outputs: vscode.CellOutput[], metadata?: vscode.WorkspaceEditEntryMetadata): void { -- GitLab