@@ -9,15 +9,16 @@ import { URI } from 'vs/base/common/uri';
99import { ResourceEdit } from 'vs/editor/browser/services/bulkEditService' ;
1010import { WorkspaceEditMetadata } from 'vs/editor/common/modes' ;
1111import { IProgress } from 'vs/platform/progress/common/progress' ;
12- import { ICellEditOperation } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
12+ import { ICellEditOperation , NotebookDocumentMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
1313import { INotebookEditorModelResolverService } from 'vs/workbench/contrib/notebook/common/notebookEditorModelResolverService' ;
1414import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService' ;
1515
1616export class ResourceNotebookCellEdit extends ResourceEdit {
1717
1818 constructor (
1919 readonly resource : URI ,
20- readonly cellEdit : ICellEditOperation ,
20+ readonly cellEdit ?: ICellEditOperation ,
21+ readonly notebookMetadata ?: NotebookDocumentMetadata ,
2122 readonly versionId ?: number ,
2223 readonly metadata ?: WorkspaceEditMetadata
2324 ) {
@@ -48,10 +49,22 @@ export class BulkCellEdits {
4849 // throw new Error(`Notebook '${first.resource}' has changed in the meantime`);
4950 // }
5051
52+ const edits : ICellEditOperation [ ] = [ ] ;
53+ let newMetadata : NotebookDocumentMetadata | undefined ;
54+ for ( let edit of group ) {
55+ if ( edit . cellEdit ) {
56+ edits . push ( edit . cellEdit ) ;
57+ }
58+ newMetadata = edit . notebookMetadata ?? newMetadata ;
59+ }
60+
61+ // set metadata
62+ if ( newMetadata ) {
63+ ref . object . notebook . updateNotebookMetadata ( newMetadata ) ;
64+ }
5165 // apply edits
52- const cellEdits = group . map ( edit => edit . cellEdit ) ;
53- this . _notebookService . transformEditsOutputs ( ref . object . notebook , cellEdits ) ;
54- ref . object . notebook . applyEdit ( ref . object . notebook . versionId , cellEdits , true ) ;
66+ this . _notebookService . transformEditsOutputs ( ref . object . notebook , edits ) ;
67+ ref . object . notebook . applyEdit ( ref . object . notebook . versionId , edits , true ) ;
5568 ref . dispose ( ) ;
5669
5770 this . _progress . report ( undefined ) ;
0 commit comments