mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Add redo action for split cells (#17947)
* add redo action for split cells
This commit is contained in:
@@ -7,6 +7,7 @@ import { IResourceUndoRedoElement, UndoRedoElementType } from 'vs/platform/undoR
|
|||||||
import { ICellModel, MoveDirection } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
import { ICellModel, MoveDirection } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
|
||||||
import { NotebookModel, SplitCell } from 'sql/workbench/services/notebook/browser/models/notebookModel';
|
import { NotebookModel, SplitCell } from 'sql/workbench/services/notebook/browser/models/notebookModel';
|
||||||
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
|
||||||
|
import { deepClone } from 'vs/base/common/objects';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
|
|
||||||
export class MoveCellEdit implements IResourceUndoRedoElement {
|
export class MoveCellEdit implements IResourceUndoRedoElement {
|
||||||
@@ -35,8 +36,10 @@ export class SplitCellEdit implements IResourceUndoRedoElement {
|
|||||||
label: string = localize('splitCellEdit', "Split Cell");
|
label: string = localize('splitCellEdit', "Split Cell");
|
||||||
resource = this.model.notebookUri;
|
resource = this.model.notebookUri;
|
||||||
private readonly cellOperation = { cell_operation: 'split_cell' };
|
private readonly cellOperation = { cell_operation: 'split_cell' };
|
||||||
|
private firstCellOriginalSource: string[] | string;
|
||||||
|
|
||||||
constructor(private model: NotebookModel, private cells: SplitCell[]) {
|
constructor(private model: NotebookModel, private cells: SplitCell[]) {
|
||||||
|
this.firstCellOriginalSource = deepClone(cells[0].cell.source);
|
||||||
}
|
}
|
||||||
|
|
||||||
undo(): void {
|
undo(): void {
|
||||||
@@ -45,7 +48,8 @@ export class SplitCellEdit implements IResourceUndoRedoElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
redo(): void {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
public insertCell(cell: ICellModel, index?: number, addToUndoStack: boolean = true): ICellModel | undefined {
|
||||||
if (this.inErrorState) {
|
if (this.inErrorState) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user