@@ -201,7 +201,8 @@ registerAction2(class ClearCellOutputsAction extends NotebookCellAction {
201
201
return ;
202
202
}
203
203
204
- 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 ) ;
205
206
206
207
const runState = notebookExecutionStateService . getCellExecution ( context . cell . uri ) ?. state ;
207
208
if ( runState !== NotebookCellExecutionState . Executing ) {
@@ -213,7 +214,7 @@ registerAction2(class ClearCellOutputsAction extends NotebookCellAction {
213
214
executionOrder : null ,
214
215
lastRunSuccess : null
215
216
}
216
- } ] , true , undefined , ( ) => undefined , undefined , true ) ;
217
+ } ] , true , undefined , ( ) => undefined , undefined , computeUndoRedo ) ;
217
218
}
218
219
}
219
220
} ) ;
@@ -256,10 +257,11 @@ registerAction2(class ClearAllCellOutputsAction extends NotebookAction {
256
257
return ;
257
258
}
258
259
260
+ const computeUndoRedo = ! editor . isReadOnly ;
259
261
editor . textModel . applyEdits (
260
262
editor . textModel . cells . map ( ( cell , index ) => ( {
261
263
editType : CellEditType . Output , index, outputs : [ ]
262
- } ) ) , true , undefined , ( ) => undefined , undefined , true ) ;
264
+ } ) ) , true , undefined , ( ) => undefined , undefined , computeUndoRedo ) ;
263
265
264
266
const clearExecutionMetadataEdits = editor . textModel . cells . map ( ( cell , index ) => {
265
267
const runState = notebookExecutionStateService . getCellExecution ( cell . uri ) ?. state ;
@@ -278,7 +280,7 @@ registerAction2(class ClearAllCellOutputsAction extends NotebookAction {
278
280
}
279
281
} ) . filter ( edit => ! ! edit ) as ICellEditOperation [ ] ;
280
282
if ( clearExecutionMetadataEdits . length ) {
281
- context . notebookEditor . textModel . applyEdits ( clearExecutionMetadataEdits , true , undefined , ( ) => undefined , undefined , true ) ;
283
+ context . notebookEditor . textModel . applyEdits ( clearExecutionMetadataEdits , true , undefined , ( ) => undefined , undefined , computeUndoRedo ) ;
282
284
}
283
285
}
284
286
} ) ;
@@ -498,7 +500,7 @@ async function setCellToLanguage(languageId: string, context: IChangeCellContext
498
500
const index = context . notebookEditor . textModel . cells . indexOf ( context . cell . model ) ;
499
501
context . notebookEditor . textModel . applyEdits (
500
502
[ { editType : CellEditType . CellLanguage , index, language : languageId } ] ,
501
- true , undefined , ( ) => undefined , undefined , true
503
+ true , undefined , ( ) => undefined , undefined , ! context . notebookEditor . isReadOnly
502
504
) ;
503
505
}
504
506
}
0 commit comments