diff --git a/src/vs/workbench/api/common/extHostNotebook.ts b/src/vs/workbench/api/common/extHostNotebook.ts index c85638f4011dee44c987731f967b2d82e8e596d9..8416274e5d7980ee3fd19a09650e50719227b630 100644 --- a/src/vs/workbench/api/common/extHostNotebook.ts +++ b/src/vs/workbench/api/common/extHostNotebook.ts @@ -13,7 +13,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions' import { CellKind, CellOutputKind, ExtHostNotebookShape, IMainContext, MainContext, MainThreadNotebookShape, NotebookCellOutputsSplice } from 'vs/workbench/api/common/extHost.protocol'; import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands'; import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors'; -import { CellEditType, CellUri, diff, ICellEditOperation, ICellInsertEdit, IErrorOutput, INotebookDisplayOrder, INotebookEditData, IOrderedMimeType, IStreamOutput, ITransformedDisplayOutputDto, mimeTypeSupportedByCore, NotebookCellsChangedEvent, NotebookCellsSplice2, sortMimeTypes } from 'vs/workbench/contrib/notebook/common/notebookCommon'; +import { CellEditType, CellUri, diff, ICellEditOperation, ICellInsertEdit, IErrorOutput, INotebookDisplayOrder, INotebookEditData, IOrderedMimeType, IStreamOutput, ITransformedDisplayOutputDto, mimeTypeSupportedByCore, NotebookCellsChangedEvent, NotebookCellsSplice2, sortMimeTypes, ICellDeleteEdit } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import { Disposable as VSCodeDisposable } from './extHostTypes'; interface IObservable { @@ -425,7 +425,8 @@ export class NotebookEditorCellEdit { this._collectedEdits.push({ editType: CellEditType.Delete, - index + index, + count: 1 }); } } @@ -495,12 +496,19 @@ export class ExtHostNotebookEditor extends Disposable implements vscode.Notebook let prev = compressedEdits[prevIndex]; if (prev.editType === CellEditType.Insert && editData.edits[i].editType === CellEditType.Insert) { - if (prev.index + prev.cells.length === editData.edits[i].index) { + if (prev.index === editData.edits[i].index) { prev.cells.push(...(editData.edits[i] as ICellInsertEdit).cells); continue; } } + if (prev.editType === CellEditType.Delete && editData.edits[i].editType === CellEditType.Delete) { + if (prev.index === editData.edits[i].index) { + prev.count += (editData.edits[i] as ICellDeleteEdit).count; + continue; + } + } + compressedEdits.push(editData.edits[i]); compressedEditsIndex++; } diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts index 83d52da64d95812fb682aaaa1d991e95ee4c9e6f..3642bc68d043a0e73713296e8b93be90b36fae68 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts @@ -224,6 +224,7 @@ export interface ICellInsertEdit { export interface ICellDeleteEdit { editType: CellEditType.Delete; index: number; + count: number; } export type ICellEditOperation = ICellInsertEdit | ICellDeleteEdit;