diff --git a/src/vs/workbench/api/browser/mainThreadNotebook.ts b/src/vs/workbench/api/browser/mainThreadNotebook.ts index 92ed06d2714a3..8795bfa3d09af 100644 --- a/src/vs/workbench/api/browser/mainThreadNotebook.ts +++ b/src/vs/workbench/api/browser/mainThreadNotebook.ts @@ -164,7 +164,7 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo return false; } this._notebookService.transformEditsOutputs(textModel, cellEdits); - return textModel.applyEdits(modelVersionId, cellEdits, true, undefined, () => undefined); + return textModel.applyEdits(modelVersionId, cellEdits, true, undefined, () => undefined, undefined); } private _isDeltaEmpty(delta: INotebookDocumentsAndEditorsDelta) { @@ -475,7 +475,7 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo this._notebookService.transformEditsOutputs(mainthreadTextModel, edits); await new Promise(resolve => { DOM.scheduleAtNextAnimationFrame(() => { - const ret = mainthreadTextModel!.applyEdits(mainthreadTextModel!.versionId, edits, true, undefined, () => undefined); + const ret = mainthreadTextModel!.applyEdits(mainthreadTextModel!.versionId, edits, true, undefined, () => undefined, undefined); resolve(ret); }); }); @@ -611,7 +611,7 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo index: textModel.cells.indexOf(cell), splices } - ], true, undefined, () => undefined); + ], true, undefined, () => undefined, undefined); } async $postMessage(editorId: string, forRendererId: string | undefined, value: any): Promise { @@ -646,7 +646,7 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo { editType: CellEditType.Unknown } - ], true, undefined, () => undefined); + ], true, undefined, () => undefined, undefined); } } diff --git a/src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts b/src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts index 7a369cd5373ed..96b5e0e7e6180 100644 --- a/src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts +++ b/src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts @@ -29,7 +29,7 @@ export class ResourceNotebookCellEdit extends ResourceEdit { export class BulkCellEdits { constructor( - undoRedoGroup: UndoRedoGroup, + private _undoRedoGroup: UndoRedoGroup, private readonly _progress: IProgress, private readonly _edits: ResourceNotebookCellEdit[], @INotebookService private readonly _notebookService: INotebookService, @@ -53,7 +53,7 @@ export class BulkCellEdits { // apply edits const edits = group.map(entry => entry.cellEdit); this._notebookService.transformEditsOutputs(ref.object.notebook, edits); - ref.object.notebook.applyEdits(ref.object.notebook.versionId, edits, true, undefined, () => undefined); + ref.object.notebook.applyEdits(ref.object.notebook.versionId, edits, true, undefined, () => undefined, this._undoRedoGroup); ref.dispose(); this._progress.report(undefined); diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts index b51ba023fde4a..5037de6a82f35 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts @@ -622,7 +622,7 @@ export async function changeCellToKind(kind: CellKind, context: INotebookCellAct metadata: cell.metadata, }] } - ], true, undefined, () => undefined, true); + ], true, undefined, () => undefined, undefined, true); const newCell = notebookEditor.viewModel.viewCells[idx]; if (!newCell) { @@ -1399,7 +1399,7 @@ registerAction2(class extends NotebookCellAction { return; } - editor.viewModel.notebookDocument.applyEdits(editor.viewModel.notebookDocument.versionId, [{ editType: CellEditType.Output, index, outputs: [] }], true, undefined, () => undefined); + editor.viewModel.notebookDocument.applyEdits(editor.viewModel.notebookDocument.versionId, [{ editType: CellEditType.Output, index, outputs: [] }], true, undefined, () => undefined, undefined); if (context.cell.metadata && context.cell.metadata?.runState !== NotebookCellRunState.Running) { context.notebookEditor.viewModel!.notebookDocument.applyEdits(context.notebookEditor.viewModel!.notebookDocument.versionId, [{ @@ -1410,7 +1410,7 @@ registerAction2(class extends NotebookCellAction { lastRunDuration: undefined, statusMessage: undefined } - }], true, undefined, () => undefined); + }], true, undefined, () => undefined, undefined); } } }); @@ -1493,7 +1493,7 @@ export class ChangeCellLanguageAction extends NotebookCellAction { context.notebookEditor.viewModel!.notebookDocument.applyEdits( context.notebookEditor.viewModel!.notebookDocument.versionId, [{ editType: CellEditType.CellLanguage, index, language: selection.languageId }], - true, undefined, () => undefined + true, undefined, () => undefined, undefined ); } } @@ -1544,7 +1544,7 @@ registerAction2(class extends NotebookAction { editor.viewModel.notebookDocument.applyEdits(editor.viewModel.notebookDocument.versionId, editor.viewModel.notebookDocument.cells.map((cell, index) => ({ editType: CellEditType.Output, index, outputs: [] - })), true, undefined, () => undefined); + })), true, undefined, () => undefined, undefined); } }); @@ -1678,7 +1678,7 @@ abstract class ChangeNotebookCellMetadataAction extends NotebookCellAction { return; } - textModel.applyEdits(textModel.versionId, [{ editType: CellEditType.Metadata, index, metadata: { ...context.cell.metadata, ...this.getMetadataDelta() } }], true, undefined, () => undefined); + textModel.applyEdits(textModel.versionId, [{ editType: CellEditType.Metadata, index, metadata: { ...context.cell.metadata, ...this.getMetadataDelta() } }], true, undefined, () => undefined, undefined); } abstract getMetadataDelta(): NotebookCellMetadata; diff --git a/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts b/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts index cd97de9aa6388..717ddec4c3ad0 100644 --- a/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts +++ b/src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts @@ -493,7 +493,8 @@ abstract class AbstractCellRenderer extends Disposable { [{ editType: CellEditType.CellLanguage, index, language: newLangauge }], true, undefined, - () => undefined + () => undefined, + undefined ); } @@ -505,7 +506,7 @@ abstract class AbstractCellRenderer extends Disposable { this.notebookEditor.textModel!.applyEdits(this.notebookEditor.textModel!.versionId, [ { editType: CellEditType.Metadata, index, metadata: result } - ], true, undefined, () => undefined); + ], true, undefined, () => undefined, undefined); } catch { } } diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts index da6c7d26b1320..a041b48b082c2 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts @@ -342,11 +342,11 @@ abstract class AbstractCellRenderer { if (templateData.currentRenderedCell.metadata?.inputCollapsed) { textModel.applyEdits(textModel.versionId, [ { editType: CellEditType.Metadata, index, metadata: { ...templateData.currentRenderedCell.metadata, inputCollapsed: false } } - ], true, undefined, () => undefined); + ], true, undefined, () => undefined, undefined); } else if (templateData.currentRenderedCell.metadata?.outputCollapsed) { textModel.applyEdits(textModel.versionId, [ { editType: CellEditType.Metadata, index, metadata: { ...templateData.currentRenderedCell.metadata, outputCollapsed: false } } - ], true, undefined, () => undefined); + ], true, undefined, () => undefined, undefined); } })); } diff --git a/src/vs/workbench/contrib/notebook/browser/view/renderers/dnd.ts b/src/vs/workbench/contrib/notebook/browser/view/renderers/dnd.ts index fbb77daf75ad6..27901ec3ca6d7 100644 --- a/src/vs/workbench/contrib/notebook/browser/view/renderers/dnd.ts +++ b/src/vs/workbench/contrib/notebook/browser/view/renderers/dnd.ts @@ -256,7 +256,7 @@ export class CellDragAndDropController extends Disposable { } private copyCells(draggedCells: ICellViewModel[], ontoCell: ICellViewModel, direction: 'above' | 'below') { - this.notebookEditor.textModel!.pushStackElement('Copy Cells', undefined); + this.notebookEditor.textModel!.pushStackElement('Copy Cells', undefined, undefined); let firstNewCell: ICellViewModel | undefined = undefined; let firstNewCellState: CellEditState = CellEditState.Preview; for (let i = 0; i < draggedCells.length; i++) { @@ -273,6 +273,6 @@ export class CellDragAndDropController extends Disposable { this.notebookEditor.focusNotebookCell(firstNewCell, firstNewCellState === CellEditState.Editing ? 'editor' : 'container'); } - this.notebookEditor.textModel!.pushStackElement('Copy Cells', undefined); + this.notebookEditor.textModel!.pushStackElement('Copy Cells', undefined, undefined); } } diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/cellEdit.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/cellEdit.ts index dda9fad2ef94d..641e043f08bbf 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/cellEdit.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/cellEdit.ts @@ -74,63 +74,3 @@ export class JoinCellEdit implements IResourceUndoRedoElement { this.cell.focusMode = CellFocusMode.Editor; } } - - -export class SplitCellEdit implements IResourceUndoRedoElement { - type: UndoRedoElementType.Resource = UndoRedoElementType.Resource; - label: string = 'Join Cell'; - constructor( - public resource: URI, - private index: number, - private cell: BaseCellViewModel, - private selections: Selection[], - private cellContents: string[], - private language: string, - private cellKind: CellKind, - private editingDelegate: IViewCellEditingDelegate - ) { - - } - - async undo(): Promise { - if (!this.editingDelegate.deleteCell) { - throw new Error('Notebook Delete Cell not implemented for Undo/Redo'); - } - - await this.cell.resolveTextModel(); - this.cell.textModel!.applyEdits([ - { - range: this.cell.textModel!.getFullModelRange(), - text: this.cellContents.join('') - } - ]); - this.cell.setSelections(this.selections); - - for (let j = 1; j < this.cellContents.length; j++) { - this.editingDelegate.deleteCell(this.index + 1, j === this.cellContents.length - 1 ? [this.cell.handle] : undefined); - } - - this.cell.focusMode = CellFocusMode.Editor; - } - - async redo(): Promise { - if (!this.editingDelegate.createCell) { - throw new Error('Notebook Insert Cell not implemented for Undo/Redo'); - } - - await this.cell.resolveTextModel(); - this.cell.textModel!.applyEdits([ - { range: this.cell.textModel!.getFullModelRange(), text: this.cellContents[0] } - ], false); - - let insertIndex = this.index + 1; - let lastCell; - for (let j = 1; j < this.cellContents.length; j++, insertIndex++) { - lastCell = this.editingDelegate.createCell(insertIndex, this.cellContents[j], this.language, this.cellKind, {}, []); - } - - if (lastCell) { - lastCell.focusMode = CellFocusMode.Editor; - } - } -} diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts index 7a3f1fdcccdee..67b82304edb01 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts @@ -29,10 +29,10 @@ import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/no import { MarkdownRenderer } from 'vs/workbench/contrib/notebook/browser/view/renderers/mdRenderer'; import { dirname } from 'vs/base/common/resources'; import { IPosition, Position } from 'vs/editor/common/core/position'; -import { SplitCellEdit, JoinCellEdit } from 'vs/workbench/contrib/notebook/browser/viewModel/cellEdit'; -import { BaseCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel'; +import { JoinCellEdit } from 'vs/workbench/contrib/notebook/browser/viewModel/cellEdit'; import { PieceTreeTextBuffer } from 'vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer'; import { MultiModelEditStackElement, SingleModelEditStackElement } from 'vs/editor/common/model/editStack'; +import { ResourceNotebookCellEdit } from 'vs/workbench/contrib/bulkEdit/browser/bulkCellEdits'; export interface INotebookEditorViewState { editingCells: { [key: number]: boolean }; @@ -640,7 +640,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD } ] } - ], synchronous, beforeSelections, () => undefined); + ], synchronous, beforeSelections, () => undefined, undefined); return this._viewCells[index]; } @@ -673,6 +673,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD synchronous, this.selectionHandles, () => endSelections, + undefined, pushUndoStop ); } @@ -698,7 +699,7 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD length, newIdx } - ], synchronous, undefined, () => [viewCell.handle]); + ], synchronous, undefined, () => [viewCell.handle], undefined); return true; } @@ -782,47 +783,30 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD const newLinesContents = this._computeCellLinesContents(cell, splitPoints); if (newLinesContents) { - const editorSelections = cell.getSelections(); const language = cell.language; const kind = cell.cellKind; - this._notebook.applyEdits(this._notebook.versionId, [ - { - editType: CellEditType.CellContent, - index, - range: undefined, - text: newLinesContents[0] - }, - { - editType: CellEditType.Replace, - index: index + 1, - count: 0, - cells: newLinesContents.slice(1).map(line => ({ - cellKind: kind, - language, - source: line, - outputs: [], - metadata: {} - })) - } - ], true, undefined, () => this.selectionHandles, false); - - this._undoService.pushElement(new SplitCellEdit( - this.uri, - index, - cell, - editorSelections, - newLinesContents, - language, - kind, - { - createCell: (index: number, source: string, language: string, type: CellKind, metadata: NotebookCellMetadata | undefined, outputs: IProcessedOutput[]) => { - return this.createCell(index, source, language, type, metadata, outputs, true, false) as BaseCellViewModel; - }, - deleteCell: (index: number) => { - this.deleteCell(index, true, false); - } - } - )); + + const textModel = await cell.resolveTextModel(); + await this._bulkEditService.apply( + [ + new ResourceTextEdit(cell.uri, { range: textModel.getFullModelRange(), text: newLinesContents[0] }), + new ResourceNotebookCellEdit(this._notebook.uri, + { + editType: CellEditType.Replace, + index: index + 1, + count: 0, + cells: newLinesContents.slice(1).map(line => ({ + cellKind: kind, + language, + source: line, + outputs: [], + metadata: {} + })) + } + ) + ], + { quotableLabel: 'Split Notebook Cell' } + ); } } diff --git a/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts b/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts index 3369f353b3c9e..8996c7dd97b0a 100644 --- a/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts +++ b/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts @@ -10,11 +10,10 @@ import { URI } from 'vs/base/common/uri'; import { NotebookCellTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookCellTextModel'; import { INotebookTextModel, NotebookCellOutputsSplice, NotebookDocumentMetadata, NotebookCellMetadata, ICellEditOperation, CellEditType, CellUri, notebookDocumentMetadataDefaults, diff, NotebookCellsChangeType, ICellDto2, TransientOptions, NotebookTextModelChangedEvent, NotebookRawContentEvent } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import { ITextSnapshot } from 'vs/editor/common/model'; -import { IUndoRedoService, UndoRedoElementType, IUndoRedoElement, IResourceUndoRedoElement } from 'vs/platform/undoRedo/common/undoRedo'; +import { IUndoRedoService, UndoRedoElementType, IUndoRedoElement, IResourceUndoRedoElement, UndoRedoGroup, IWorkspaceUndoRedoElement } from 'vs/platform/undoRedo/common/undoRedo'; import { MoveCellEdit, SpliceCellsEdit, CellMetadataEdit } from 'vs/workbench/contrib/notebook/common/model/cellEdit'; import { ITextModelService } from 'vs/editor/common/services/resolverService'; import { IModeService } from 'vs/editor/common/services/modeService'; -import { IRange } from 'vs/editor/common/core/range'; export class NotebookTextModelSnapshot implements ITextSnapshot { @@ -55,21 +54,25 @@ export class NotebookTextModelSnapshot implements ITextSnapshot { } -class StackOperation implements IResourceUndoRedoElement { - type: UndoRedoElementType.Resource; +class StackOperation implements IWorkspaceUndoRedoElement { + type: UndoRedoElementType.Workspace; private _operations: IUndoRedoElement[] = []; private _beginSelectionState: number[] | undefined = undefined; private _resultSelectionState: number[] | undefined = undefined; - constructor(readonly resource: URI, readonly label: string, private _delayedEmitter: DelayedEmitter, selectionState: number[] | undefined) { - this.type = UndoRedoElementType.Resource; + constructor(readonly resource: URI, readonly label: string, readonly undoRedoGroup: UndoRedoGroup | undefined, private _delayedEmitter: DelayedEmitter, selectionState: number[] | undefined) { + this.type = UndoRedoElementType.Workspace; this._beginSelectionState = selectionState; } + get resources(): readonly URI[] { + return [this.resource]; + } pushEndSelectionState(selectionState: number[] | undefined) { this._resultSelectionState = selectionState; } + pushEditOperation(element: IUndoRedoElement, beginSelectionState: number[] | undefined, resultSelectionState: number[] | undefined) { if (this._operations.length === 0) { this._beginSelectionState = this._beginSelectionState || beginSelectionState; @@ -101,15 +104,15 @@ export class NotebookOperationManager { } - pushStackElement(label: string, selectionState: number[] | undefined) { + pushStackElement(label: string, selectionState: number[] | undefined, undoRedoGroup: UndoRedoGroup | undefined) { if (this._pendingStackOperation) { this._pendingStackOperation.pushEndSelectionState(selectionState); - this._undoService.pushElement(this._pendingStackOperation); + this._undoService.pushElement(this._pendingStackOperation, this._pendingStackOperation.undoRedoGroup); this._pendingStackOperation = null; return; } - this._pendingStackOperation = new StackOperation(this._resource, label, this._delayedEmitter, selectionState); + this._pendingStackOperation = new StackOperation(this._resource, label, undoRedoGroup, this._delayedEmitter, selectionState); } pushEditOperation(element: IUndoRedoElement, beginSelectionState: number[] | undefined, resultSelectionState: number[] | undefined) { @@ -287,17 +290,17 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel super.dispose(); } - pushStackElement(label: string, selectionState: number[] | undefined) { - this._operationManager.pushStackElement(label, selectionState); + pushStackElement(label: string, selectionState: number[] | undefined, undoRedoGroup: UndoRedoGroup | undefined) { + this._operationManager.pushStackElement(label, selectionState, undoRedoGroup); } - applyEdits(modelVersionId: number, rawEdits: ICellEditOperation[], synchronous: boolean, beginSelectionState: number[] | undefined, endSelectionsComputer: () => number[] | undefined, computeUndoRedo: boolean = true): boolean { + applyEdits(modelVersionId: number, rawEdits: ICellEditOperation[], synchronous: boolean, beginSelectionState: number[] | undefined, endSelectionsComputer: () => number[] | undefined, undoRedoGroup: UndoRedoGroup | undefined, computeUndoRedo: boolean = true): boolean { if (modelVersionId !== this._versionId) { return false; } this._eventEmitter.beginDeferredEmit(); - this.pushStackElement('edit', beginSelectionState); + this.pushStackElement('edit', beginSelectionState, undoRedoGroup); const edits = rawEdits.map((edit, index) => { return { @@ -354,10 +357,6 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel case CellEditType.Move: this._moveCellToIdx(edit.index, edit.length, edit.newIdx, synchronous, computeUndoRedo, undefined, undefined); break; - case CellEditType.CellContent: - // TODO@rebornix, _replaceCellContent is async and does not push undo element - this._replaceCellContent(this._cells[edit.index], edit.range, edit.text); - break; case CellEditType.Unknown: this._handleUnknownChange(); break; @@ -365,7 +364,7 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel } const endSelections = endSelectionsComputer(); - this.pushStackElement('edit', endSelections); + this.pushStackElement('edit', endSelections, undefined); this._eventEmitter.endDeferredEmit(endSelections); return true; } @@ -678,17 +677,6 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel return true; } - async _replaceCellContent(cell: NotebookCellTextModel, range: IRange | undefined, text: string) { - const ref = await cell.resolveTextModelRef(); - const textModel = ref.object.textEditorModel; - - textModel.applyEdits([ - { range: range || textModel.getFullModelRange(), text: text } - ], false); - - ref.dispose(); - } - private _assertIndex(index: number) { if (index < 0 || index >= this._cells.length) { throw new Error(`model index out of range ${index}`); diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts index b48010c800d17..4b3bbab2304e6 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts @@ -23,7 +23,6 @@ import { IRevertOptions } from 'vs/workbench/common/editor'; import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel'; import { IDisposable } from 'vs/base/common/lifecycle'; import { IFileStatWithMetadata } from 'vs/platform/files/common/files'; -import { IRange } from 'vs/editor/common/core/range'; import { ThemeColor } from 'vs/platform/theme/common/themeService'; export enum CellKind { @@ -482,18 +481,11 @@ export interface ICellMoveEdit { newIdx: number; } -export interface ICellContentEdit { - editType: CellEditType.CellContent; - index: number; - range: IRange | undefined; - text: string; -} - export interface IDocumentUnknownEdit { editType: CellEditType.Unknown; } -export type ICellEditOperation = ICellReplaceEdit | ICellOutputEdit | ICellMetadataEdit | ICellLanguageEdit | IDocumentMetadataEdit | ICellOutputsSpliceEdit | ICellMoveEdit | ICellContentEdit | IDocumentUnknownEdit; +export type ICellEditOperation = ICellReplaceEdit | ICellOutputEdit | ICellMetadataEdit | ICellLanguageEdit | IDocumentMetadataEdit | ICellOutputsSpliceEdit | ICellMoveEdit | IDocumentUnknownEdit; export interface INotebookEditData { documentVersionId: number; diff --git a/src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts b/src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts index 45f9217ef3d44..93572f226eeb8 100644 --- a/src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts +++ b/src/vs/workbench/contrib/notebook/test/notebookTextModel.test.ts @@ -32,7 +32,7 @@ suite('NotebookTextModel', () => { textModel.applyEdits(textModel.versionId, [ { editType: CellEditType.Replace, index: 1, count: 0, cells: [new TestCell(viewModel.viewType, 5, 'var e = 5;', 'javascript', CellKind.Code, [], textModelService)] }, { editType: CellEditType.Replace, index: 3, count: 0, cells: [new TestCell(viewModel.viewType, 6, 'var f = 6;', 'javascript', CellKind.Code, [], textModelService)] }, - ], true, undefined, () => undefined); + ], true, undefined, () => undefined, undefined); assert.equal(textModel.cells.length, 6); @@ -57,7 +57,7 @@ suite('NotebookTextModel', () => { textModel.applyEdits(textModel.versionId, [ { editType: CellEditType.Replace, index: 1, count: 0, cells: [new TestCell(viewModel.viewType, 5, 'var e = 5;', 'javascript', CellKind.Code, [], textModelService)] }, { editType: CellEditType.Replace, index: 1, count: 0, cells: [new TestCell(viewModel.viewType, 6, 'var f = 6;', 'javascript', CellKind.Code, [], textModelService)] }, - ], true, undefined, () => undefined); + ], true, undefined, () => undefined, undefined); assert.equal(textModel.cells.length, 6); @@ -82,7 +82,7 @@ suite('NotebookTextModel', () => { textModel.applyEdits(textModel.versionId, [ { editType: CellEditType.Replace, index: 1, count: 1, cells: [] }, { editType: CellEditType.Replace, index: 3, count: 1, cells: [] }, - ], true, undefined, () => undefined); + ], true, undefined, () => undefined, undefined); assert.equal(textModel.cells[0].getValue(), 'var a = 1;'); assert.equal(textModel.cells[1].getValue(), 'var c = 3;'); @@ -105,7 +105,7 @@ suite('NotebookTextModel', () => { textModel.applyEdits(textModel.versionId, [ { editType: CellEditType.Replace, index: 1, count: 1, cells: [] }, { editType: CellEditType.Replace, index: 3, count: 0, cells: [new TestCell(viewModel.viewType, 5, 'var e = 5;', 'javascript', CellKind.Code, [], textModelService)] }, - ], true, undefined, () => undefined); + ], true, undefined, () => undefined, undefined); assert.equal(textModel.cells.length, 4); @@ -130,7 +130,7 @@ suite('NotebookTextModel', () => { textModel.applyEdits(textModel.versionId, [ { editType: CellEditType.Replace, index: 1, count: 1, cells: [] }, { editType: CellEditType.Replace, index: 1, count: 0, cells: [new TestCell(viewModel.viewType, 5, 'var e = 5;', 'javascript', CellKind.Code, [], textModelService)] }, - ], true, undefined, () => undefined); + ], true, undefined, () => undefined, undefined); assert.equal(textModel.cells.length, 4); assert.equal(textModel.cells[0].getValue(), 'var a = 1;'); @@ -154,7 +154,7 @@ suite('NotebookTextModel', () => { (editor, viewModel, textModel) => { textModel.applyEdits(textModel.versionId, [ { editType: CellEditType.Replace, index: 1, count: 1, cells: [new TestCell(viewModel.viewType, 5, 'var e = 5;', 'javascript', CellKind.Code, [], textModelService)] }, - ], true, undefined, () => undefined); + ], true, undefined, () => undefined, undefined); assert.equal(textModel.cells.length, 4); assert.equal(textModel.cells[0].getValue(), 'var a = 1;'); @@ -180,7 +180,7 @@ suite('NotebookTextModel', () => { index: Number.MAX_VALUE, editType: CellEditType.Output, outputs: [] - }], true, undefined, () => undefined); + }], true, undefined, () => undefined, undefined); }); // invalid index 2 @@ -189,7 +189,7 @@ suite('NotebookTextModel', () => { index: -1, editType: CellEditType.Output, outputs: [] - }], true, undefined, () => undefined); + }], true, undefined, () => undefined, undefined); }); textModel.applyEdits(textModel.versionId, [{ @@ -200,7 +200,7 @@ suite('NotebookTextModel', () => { outputId: 'someId', data: { 'text/markdown': '_Hello_' } }] - }], true, undefined, () => undefined); + }], true, undefined, () => undefined, undefined); assert.equal(textModel.cells.length, 1); assert.equal(textModel.cells[0].outputs.length, 1); @@ -225,7 +225,7 @@ suite('NotebookTextModel', () => { index: Number.MAX_VALUE, editType: CellEditType.Metadata, metadata: { editable: false } - }], true, undefined, () => undefined); + }], true, undefined, () => undefined, undefined); }); // invalid index 2 @@ -234,14 +234,14 @@ suite('NotebookTextModel', () => { index: -1, editType: CellEditType.Metadata, metadata: { editable: false } - }], true, undefined, () => undefined); + }], true, undefined, () => undefined, undefined); }); textModel.applyEdits(textModel.versionId, [{ index: 0, editType: CellEditType.Metadata, metadata: { editable: false }, - }], true, undefined, () => undefined); + }], true, undefined, () => undefined, undefined); assert.equal(textModel.cells.length, 1); assert.equal(textModel.cells[0].metadata?.editable, false); @@ -270,7 +270,7 @@ suite('NotebookTextModel', () => { textModel.applyEdits(textModel.versionId, [ { editType: CellEditType.Replace, index: 1, count: 1, cells: [] }, { editType: CellEditType.Replace, index: 1, count: 0, cells: [new TestCell(viewModel.viewType, 5, 'var e = 5;', 'javascript', CellKind.Code, [], textModelService)] }, - ], true, undefined, () => [0]); + ], true, undefined, () => [0], undefined); assert.equal(textModel.cells.length, 4); assert.equal(textModel.cells[0].getValue(), 'var a = 1;'); @@ -311,7 +311,7 @@ suite('NotebookTextModel', () => { editType: CellEditType.Metadata, metadata: { editable: false }, } - ], true, undefined, () => [0]); + ], true, undefined, () => [0], undefined); assert.notEqual(changeEvent, undefined); assert.equal(changeEvent!.rawEvents.length, 2);