@@ -134,7 +134,7 @@ registerAction2(class DeleteCellAction extends NotebookCellAction {
134
134
mac : {
135
135
primary : KeyMod . CtrlCmd | KeyCode . Backspace
136
136
} ,
137
- when : ContextKeyExpr . and ( NOTEBOOK_EDITOR_FOCUSED , NOTEBOOK_EDITOR_EDITABLE , ContextKeyExpr . not ( InputFocusedContextKey ) ) ,
137
+ when : ContextKeyExpr . and ( NOTEBOOK_EDITOR_FOCUSED , ContextKeyExpr . not ( InputFocusedContextKey ) ) ,
138
138
weight : KeybindingWeight . WorkbenchContrib
139
139
} ,
140
140
menu : [
@@ -145,7 +145,6 @@ registerAction2(class DeleteCellAction extends NotebookCellAction {
145
145
} ,
146
146
{
147
147
id : MenuId . InteractiveCellDelete ,
148
- when : NOTEBOOK_EDITOR_EDITABLE ,
149
148
group : CELL_TITLE_CELL_GROUP_ID
150
149
}
151
150
] ,
@@ -154,7 +153,7 @@ registerAction2(class DeleteCellAction extends NotebookCellAction {
154
153
}
155
154
156
155
async runWithContext ( accessor : ServicesAccessor , context : INotebookCellActionContext ) {
157
- if ( ! context . notebookEditor . hasModel ( ) || context . notebookEditor . isReadOnly ) {
156
+ if ( ! context . notebookEditor . hasModel ( ) ) {
158
157
return ;
159
158
}
160
159
@@ -202,7 +201,8 @@ registerAction2(class ClearCellOutputsAction extends NotebookCellAction {
202
201
return ;
203
202
}
204
203
205
- editor . textModel . applyEdits ( [ { editType : CellEditType . Output , index, outputs : [ ] } ] , true , undefined , ( ) => undefined , undefined , true ) ;
204
+ const computeUndoRedo = ! editor . isReadOnly ;
205
+ editor . textModel . applyEdits ( [ { editType : CellEditType . Output , index, outputs : [ ] } ] , true , undefined , ( ) => undefined , undefined , computeUndoRedo ) ;
206
206
207
207
const runState = notebookExecutionStateService . getCellExecution ( context . cell . uri ) ?. state ;
208
208
if ( runState !== NotebookCellExecutionState . Executing ) {
@@ -214,7 +214,7 @@ registerAction2(class ClearCellOutputsAction extends NotebookCellAction {
214
214
executionOrder : null ,
215
215
lastRunSuccess : null
216
216
}
217
- } ] , true , undefined , ( ) => undefined , undefined , true ) ;
217
+ } ] , true , undefined , ( ) => undefined , undefined , computeUndoRedo ) ;
218
218
}
219
219
}
220
220
} ) ;
@@ -257,10 +257,11 @@ registerAction2(class ClearAllCellOutputsAction extends NotebookAction {
257
257
return ;
258
258
}
259
259
260
+ const computeUndoRedo = ! editor . isReadOnly ;
260
261
editor . textModel . applyEdits (
261
262
editor . textModel . cells . map ( ( cell , index ) => ( {
262
263
editType : CellEditType . Output , index, outputs : [ ]
263
- } ) ) , true , undefined , ( ) => undefined , undefined , true ) ;
264
+ } ) ) , true , undefined , ( ) => undefined , undefined , computeUndoRedo ) ;
264
265
265
266
const clearExecutionMetadataEdits = editor . textModel . cells . map ( ( cell , index ) => {
266
267
const runState = notebookExecutionStateService . getCellExecution ( cell . uri ) ?. state ;
@@ -279,7 +280,7 @@ registerAction2(class ClearAllCellOutputsAction extends NotebookAction {
279
280
}
280
281
} ) . filter ( edit => ! ! edit ) as ICellEditOperation [ ] ;
281
282
if ( clearExecutionMetadataEdits . length ) {
282
- context . notebookEditor . textModel . applyEdits ( clearExecutionMetadataEdits , true , undefined , ( ) => undefined , undefined , true ) ;
283
+ context . notebookEditor . textModel . applyEdits ( clearExecutionMetadataEdits , true , undefined , ( ) => undefined , undefined , computeUndoRedo ) ;
283
284
}
284
285
}
285
286
} ) ;
@@ -499,7 +500,7 @@ async function setCellToLanguage(languageId: string, context: IChangeCellContext
499
500
const index = context . notebookEditor . textModel . cells . indexOf ( context . cell . model ) ;
500
501
context . notebookEditor . textModel . applyEdits (
501
502
[ { editType : CellEditType . CellLanguage , index, language : languageId } ] ,
502
- true , undefined , ( ) => undefined , undefined , true
503
+ true , undefined , ( ) => undefined , undefined , ! context . notebookEditor . isReadOnly
503
504
) ;
504
505
}
505
506
}
0 commit comments