@@ -123,6 +123,7 @@ export function runDeleteAction(editor: IActiveNotebookEditor, cell: ICellViewMo
123
123
const targetCellIndex = editor . getCellIndex ( cell ) ;
124
124
const containingSelection = selections . find ( selection => selection . start <= targetCellIndex && targetCellIndex < selection . end ) ;
125
125
126
+ const computeUndoRedo = ! editor . isReadOnly || textModel . viewType === 'interactive' ;
126
127
if ( containingSelection ) {
127
128
const edits : ICellReplaceEdit [ ] = selections . reverse ( ) . map ( selection => ( {
128
129
editType : CellEditType . Replace , index : selection . start , count : selection . end - selection . start , cells : [ ]
@@ -143,7 +144,7 @@ export function runDeleteAction(editor: IActiveNotebookEditor, cell: ICellViewMo
143
144
return { kind : SelectionStateType . Index , focus : { start : 0 , end : 0 } , selections : [ { start : 0 , end : 0 } ] } ;
144
145
}
145
146
}
146
- } , undefined , true ) ;
147
+ } , undefined , computeUndoRedo ) ;
147
148
} else {
148
149
const focus = editor . getFocus ( ) ;
149
150
const edits : ICellReplaceEdit [ ] = [ {
@@ -169,14 +170,14 @@ export function runDeleteAction(editor: IActiveNotebookEditor, cell: ICellViewMo
169
170
170
171
textModel . applyEdits ( edits , true , { kind : SelectionStateType . Index , focus : editor . getFocus ( ) , selections : editor . getSelections ( ) } , ( ) => ( {
171
172
kind : SelectionStateType . Index , focus : newFocus , selections : finalSelections
172
- } ) , undefined , true ) ;
173
+ } ) , undefined , computeUndoRedo ) ;
173
174
} else {
174
175
// users decide to delete a cell out of current focus/selection
175
176
const newFocus = focus . start > targetCellIndex ? { start : focus . start - 1 , end : focus . end - 1 } : focus ;
176
177
177
178
textModel . applyEdits ( edits , true , { kind : SelectionStateType . Index , focus : editor . getFocus ( ) , selections : editor . getSelections ( ) } , ( ) => ( {
178
179
kind : SelectionStateType . Index , focus : newFocus , selections : finalSelections
179
- } ) , undefined , true ) ;
180
+ } ) , undefined , computeUndoRedo ) ;
180
181
}
181
182
}
182
183
}
0 commit comments