Skip to content

Commit 833cbca

Browse files
committed
enabled core cell delete for IW and undo operations
1 parent 8cf99fe commit 833cbca

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ export class BulkCellEdits {
7272

7373
// apply edits
7474
const edits = group.map(entry => entry.cellEdit);
75-
ref.object.notebook.applyEdits(edits, true, undefined, () => undefined, this._undoRedoGroup, true);
75+
const computeUndo = !ref.object.isReadonly;
76+
ref.object.notebook.applyEdits(edits, true, undefined, () => undefined, this._undoRedoGroup, computeUndo);
7677
ref.dispose();
7778

7879
this._progress.report(undefined);

src/vs/workbench/contrib/notebook/browser/controller/cellOperations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,6 @@ export function insertCellAtIndex(viewModel: NotebookViewModel, index: number, s
649649
}
650650
]
651651
}
652-
], synchronous, { kind: SelectionStateType.Index, focus: viewModel.getFocus(), selections: viewModel.getSelections() }, () => endSelections, undefined, pushUndoStop);
652+
], synchronous, { kind: SelectionStateType.Index, focus: viewModel.getFocus(), selections: viewModel.getSelections() }, () => endSelections, undefined, pushUndoStop && !viewModel.options.isReadOnly);
653653
return viewModel.cellAt(index)!;
654654
}

src/vs/workbench/contrib/notebook/browser/controller/editActions.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ registerAction2(class DeleteCellAction extends NotebookCellAction {
134134
mac: {
135135
primary: KeyMod.CtrlCmd | KeyCode.Backspace
136136
},
137-
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, ContextKeyExpr.not(InputFocusedContextKey)),
137+
when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey)),
138138
weight: KeybindingWeight.WorkbenchContrib
139139
},
140140
menu: [
@@ -145,7 +145,6 @@ registerAction2(class DeleteCellAction extends NotebookCellAction {
145145
},
146146
{
147147
id: MenuId.InteractiveCellDelete,
148-
when: NOTEBOOK_EDITOR_EDITABLE,
149148
group: CELL_TITLE_CELL_GROUP_ID
150149
}
151150
],
@@ -154,7 +153,7 @@ registerAction2(class DeleteCellAction extends NotebookCellAction {
154153
}
155154

156155
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext) {
157-
if (!context.notebookEditor.hasModel() || context.notebookEditor.isReadOnly) {
156+
if (!context.notebookEditor.hasModel()) {
158157
return;
159158
}
160159

src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -954,9 +954,6 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
954954
}
955955

956956
async undo() {
957-
if (this._options.isReadOnly) {
958-
return null;
959-
}
960957

961958
const editStack = this._undoService.getElements(this.uri);
962959
const element = editStack.past.length ? editStack.past[editStack.past.length - 1] : undefined;
@@ -974,9 +971,6 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
974971
}
975972

976973
async redo() {
977-
if (this._options.isReadOnly) {
978-
return null;
979-
}
980974

981975
const editStack = this._undoService.getElements(this.uri);
982976
const element = editStack.future[0];

0 commit comments

Comments
 (0)