diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts index 04740c1163d..46fd3c2e491 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts @@ -1385,7 +1385,8 @@ abstract class ChangeNotebookCellMetadataAction extends NotebookCellAction { const metadataDelta = this.getMetadataDelta(); const edits: ICellEditOperation[] = []; - for (const cell of context.selectedCells || []) { + const targetCells = (context.cell ? [context.cell] : context.selectedCells) ?? []; + for (const cell of targetCells) { const index = textModel.cells.indexOf(cell.model); if (index >= 0) { edits.push({ editType: CellEditType.Metadata, index, metadata: { ...context.cell.metadata, ...metadataDelta } });