diff --git a/src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts b/src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts index 0e870b7b639..c2dc0915ead 100644 --- a/src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts +++ b/src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts @@ -72,7 +72,8 @@ export class BulkCellEdits { // apply edits const edits = group.map(entry => entry.cellEdit); - ref.object.notebook.applyEdits(edits, true, undefined, () => undefined, this._undoRedoGroup, true); + const computeUndo = !ref.object.isReadonly; + ref.object.notebook.applyEdits(edits, true, undefined, () => undefined, this._undoRedoGroup, computeUndo); ref.dispose(); this._progress.report(undefined); diff --git a/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.ts b/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.ts index 08f3f326881..fe5975a2c3d 100644 --- a/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.ts +++ b/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.ts @@ -649,6 +649,6 @@ export function insertCellAtIndex(viewModel: NotebookViewModel, index: number, s } ] } - ], synchronous, { kind: SelectionStateType.Index, focus: viewModel.getFocus(), selections: viewModel.getSelections() }, () => endSelections, undefined, pushUndoStop); + ], synchronous, { kind: SelectionStateType.Index, focus: viewModel.getFocus(), selections: viewModel.getSelections() }, () => endSelections, undefined, pushUndoStop && !viewModel.options.isReadOnly); return viewModel.cellAt(index)!; } diff --git a/src/vs/workbench/contrib/notebook/browser/controller/editActions.ts b/src/vs/workbench/contrib/notebook/browser/controller/editActions.ts index 06e089a7c6b..8efd2d548a8 100644 --- a/src/vs/workbench/contrib/notebook/browser/controller/editActions.ts +++ b/src/vs/workbench/contrib/notebook/browser/controller/editActions.ts @@ -134,7 +134,7 @@ registerAction2(class DeleteCellAction extends NotebookCellAction { mac: { primary: KeyMod.CtrlCmd | KeyCode.Backspace }, - when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_EDITABLE, ContextKeyExpr.not(InputFocusedContextKey)), + when: ContextKeyExpr.and(NOTEBOOK_EDITOR_FOCUSED, ContextKeyExpr.not(InputFocusedContextKey)), weight: KeybindingWeight.WorkbenchContrib }, menu: [ @@ -145,7 +145,6 @@ registerAction2(class DeleteCellAction extends NotebookCellAction { }, { id: MenuId.InteractiveCellDelete, - when: NOTEBOOK_EDITOR_EDITABLE, group: CELL_TITLE_CELL_GROUP_ID } ], @@ -154,7 +153,7 @@ registerAction2(class DeleteCellAction extends NotebookCellAction { } async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext) { - if (!context.notebookEditor.hasModel() || context.notebookEditor.isReadOnly) { + if (!context.notebookEditor.hasModel()) { return; } diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.ts index 080427cbac2..4229a1a96d9 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.ts @@ -954,9 +954,6 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD } async undo() { - if (this._options.isReadOnly) { - return null; - } const editStack = this._undoService.getElements(this.uri); const element = editStack.past.length ? editStack.past[editStack.past.length - 1] : undefined; @@ -974,9 +971,6 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD } async redo() { - if (this._options.isReadOnly) { - return null; - } const editStack = this._undoService.getElements(this.uri); const element = editStack.future[0];