diff --git a/src/sql/workbench/services/notebook/browser/models/cellEdit.ts b/src/sql/workbench/services/notebook/browser/models/cellEdit.ts index 7a58f42eb1..6b31aaa65f 100644 --- a/src/sql/workbench/services/notebook/browser/models/cellEdit.ts +++ b/src/sql/workbench/services/notebook/browser/models/cellEdit.ts @@ -7,6 +7,7 @@ import { IResourceUndoRedoElement, UndoRedoElementType } from 'vs/platform/undoR import { ICellModel, MoveDirection } from 'sql/workbench/services/notebook/browser/models/modelInterfaces'; import { NotebookModel, SplitCell } from 'sql/workbench/services/notebook/browser/models/notebookModel'; import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys'; +import { deepClone } from 'vs/base/common/objects'; import { localize } from 'vs/nls'; export class MoveCellEdit implements IResourceUndoRedoElement { @@ -35,8 +36,10 @@ export class SplitCellEdit implements IResourceUndoRedoElement { label: string = localize('splitCellEdit', "Split Cell"); resource = this.model.notebookUri; private readonly cellOperation = { cell_operation: 'split_cell' }; + private firstCellOriginalSource: string[] | string; constructor(private model: NotebookModel, private cells: SplitCell[]) { + this.firstCellOriginalSource = deepClone(cells[0].cell.source); } undo(): void { @@ -45,7 +48,8 @@ export class SplitCellEdit implements IResourceUndoRedoElement { } redo(): void { - // no-op currently, will add support on next release + this.model.splitCells(this.cells, this.firstCellOriginalSource); + this.model.sendNotebookTelemetryActionEvent(TelemetryKeys.NbTelemetryAction.RedoCell, this.cellOperation); } } diff --git a/src/sql/workbench/services/notebook/browser/models/notebookModel.ts b/src/sql/workbench/services/notebook/browser/models/notebookModel.ts index fa618cf6cb..1ce8cadf70 100644 --- a/src/sql/workbench/services/notebook/browser/models/notebookModel.ts +++ b/src/sql/workbench/services/notebook/browser/models/notebookModel.ts @@ -706,6 +706,21 @@ export class NotebookModel extends Disposable implements INotebookModel { } } + public splitCells(cells: SplitCell[], firstCellOriginalSource: string | string[]): void { + cells[0].cell.source = firstCellOriginalSource; + cells[0].cell.isEditMode = true; + this.updateActiveCell(cells[0].cell); + this._contentChangedEmitter.fire({ + changeType: NotebookChangeType.CellsModified, + cells: [cells[0].cell], + cellIndex: 0 + }); + + for (let i = 1; i < cells.length; i++) { + this.insertCell(cells[i].cell, undefined, false); + } + } + public insertCell(cell: ICellModel, index?: number, addToUndoStack: boolean = true): ICellModel | undefined { if (this.inErrorState) { return undefined;