Skip to content

Commit eb05e94

Browse files
committed
Send cell metadata changes to EH, add onDidChangeCellMetadata event
1 parent 8d51d4a commit eb05e94

15 files changed

Lines changed: 89 additions & 66 deletions

src/vs/vscode.proposed.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,11 @@ declare module 'vscode' {
15991599
readonly language: string;
16001600
}
16011601

1602+
export interface NotebookCellMetadataChangeEvent {
1603+
readonly document: NotebookDocument;
1604+
readonly cell: NotebookCell;
1605+
}
1606+
16021607
export interface NotebookCellData {
16031608
readonly cellKind: CellKind;
16041609
readonly source: string;
@@ -1789,6 +1794,7 @@ declare module 'vscode' {
17891794
export const onDidChangeNotebookCells: Event<NotebookCellsChangeEvent>;
17901795
export const onDidChangeCellOutputs: Event<NotebookCellOutputsChangeEvent>;
17911796
export const onDidChangeCellLanguage: Event<NotebookCellLanguageChangeEvent>;
1797+
export const onDidChangeCellMetadata: Event<NotebookCellMetadataChangeEvent>;
17921798
/**
17931799
* Create a document that is the concatenation of all notebook cells. By default all code-cells are included
17941800
* but a selector can be provided to narrow to down the set of cells.

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
973973
checkProposedApiEnabled(extension);
974974
return extHostNotebook.onDidChangeCellLanguage(listener, thisArgs, disposables);
975975
},
976+
onDidChangeCellMetadata(listener, thisArgs?, disposables?) {
977+
checkProposedApiEnabled(extension);
978+
return extHostNotebook.onDidChangeCellMetadata(listener, thisArgs, disposables);
979+
},
976980
createConcatTextDocument(notebook, selector) {
977981
checkProposedApiEnabled(extension);
978982
return new ExtHostNotebookConcatDocument(extHostNotebook, extHostDocuments, notebook, selector);

src/vs/workbench/api/common/extHostNotebook.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
1414
import { CellKind, ExtHostNotebookShape, IMainContext, MainContext, MainThreadNotebookShape, NotebookCellOutputsSplice, MainThreadDocumentsShape, INotebookEditorPropertiesChangeData, INotebookDocumentsAndEditorsDelta } from 'vs/workbench/api/common/extHost.protocol';
1515
import { ExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
1616
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
17-
import { CellEditType, diff, ICellEditOperation, ICellInsertEdit, INotebookDisplayOrder, INotebookEditData, NotebookCellsChangedEvent, NotebookCellsSplice2, ICellDeleteEdit, notebookDocumentMetadataDefaults, NotebookCellsChangeType, NotebookDataDto, IOutputRenderRequest, IOutputRenderResponse, IOutputRenderResponseOutputInfo, IOutputRenderResponseCellInfo, IRawOutput, CellOutputKind, IProcessedOutput, INotebookKernelInfoDto2, IMainCellDto } from 'vs/workbench/contrib/notebook/common/notebookCommon';
17+
import { CellEditType, diff, ICellEditOperation, ICellInsertEdit, INotebookDisplayOrder, INotebookEditData, NotebookCellsChangedEvent, NotebookCellsSplice2, ICellDeleteEdit, notebookDocumentMetadataDefaults, NotebookCellsChangeType, NotebookDataDto, IOutputRenderRequest, IOutputRenderResponse, IOutputRenderResponseOutputInfo, IOutputRenderResponseCellInfo, IRawOutput, CellOutputKind, IProcessedOutput, INotebookKernelInfoDto2, IMainCellDto, NotebookCellMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
1818
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
1919
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
2020
import { ExtHostDocumentData } from 'vs/workbench/api/common/extHostDocumentData';
@@ -52,6 +52,7 @@ interface INotebookEventEmitter {
5252
emitModelChange(events: vscode.NotebookCellsChangeEvent): void;
5353
emitCellOutputsChange(event: vscode.NotebookCellOutputsChangeEvent): void;
5454
emitCellLanguageChange(event: vscode.NotebookCellLanguageChangeEvent): void;
55+
emitCellMetadataChange(event: vscode.NotebookCellMetadataChangeEvent): void;
5556
}
5657

5758
const addIdToOutput = (output: IRawOutput, id = UUID.generateUuid()): IProcessedOutput => output.outputKind === CellOutputKind.Rich
@@ -172,15 +173,18 @@ export class ExtHostCell extends Disposable implements vscode.NotebookCell {
172173
}
173174

174175
set metadata(newMetadata: vscode.NotebookCellMetadata) {
176+
this.setMetadata(newMetadata);
177+
this._updateMetadata();
178+
}
179+
180+
setMetadata(newMetadata: vscode.NotebookCellMetadata): void {
175181
// Don't apply metadata defaults here, 'undefined' means 'inherit from document metadata'
176182
this._metadataChangeListener.dispose();
177183
const observableMetadata = getObservable(newMetadata);
178184
this._metadata = observableMetadata.proxy;
179185
this._metadataChangeListener = this._register(observableMetadata.onDidChange(() => {
180186
this._updateMetadata();
181187
}));
182-
183-
this._updateMetadata();
184188
}
185189

186190
private _updateMetadata(): Promise<void> {
@@ -346,7 +350,7 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
346350

347351
get isDirty() { return false; }
348352

349-
accpetModelChanged(event: NotebookCellsChangedEvent): void {
353+
acceptModelChanged(event: NotebookCellsChangedEvent): void {
350354
this._versionId = event.versionId;
351355
if (event.kind === NotebookCellsChangeType.Initialize) {
352356
this.$spliceNotebookCells(event.changes, true);
@@ -360,6 +364,8 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
360364
this.$clearAllCellOutputs();
361365
} else if (event.kind === NotebookCellsChangeType.ChangeLanguage) {
362366
this.$changeCellLanguage(event.index, event.language);
367+
} else if (event.kind === NotebookCellsChangeType.ChangeMetadata) {
368+
this.$changeCellMetadata(event.index, event.metadata);
363369
}
364370
}
365371

@@ -461,6 +467,13 @@ export class ExtHostNotebookDocument extends Disposable implements vscode.Notebo
461467
this._emitter.emitCellLanguageChange(event);
462468
}
463469

470+
private $changeCellMetadata(index: number, newMetadata: NotebookCellMetadata): void {
471+
const cell = this.cells[index];
472+
cell.setMetadata(newMetadata);
473+
const event: vscode.NotebookCellMetadataChangeEvent = { document: this, cell };
474+
this._emitter.emitCellMetadataChange(event);
475+
}
476+
464477
async eventuallyUpdateCellOutputs(cell: ExtHostCell, diffs: ISplice<IProcessedOutput>[]) {
465478
let renderers = new Set<number>();
466479
let outputDtos: NotebookCellOutputsSplice[] = diffs.map(diff => {
@@ -888,6 +901,8 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
888901
readonly onDidChangeCellOutputs = this._onDidChangeCellOutputs.event;
889902
private readonly _onDidChangeCellLanguage = new Emitter<vscode.NotebookCellLanguageChangeEvent>();
890903
readonly onDidChangeCellLanguage = this._onDidChangeCellLanguage.event;
904+
private readonly _onDidChangeCellMetadata = new Emitter<vscode.NotebookCellMetadataChangeEvent>();
905+
readonly onDidChangeCellMetadata = this._onDidChangeCellMetadata.event;
891906
private readonly _onDidChangeActiveNotebookEditor = new Emitter<vscode.NotebookEditor | undefined>();
892907
readonly onDidChangeActiveNotebookEditor = this._onDidChangeActiveNotebookEditor.event;
893908

@@ -1179,7 +1194,10 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
11791194
},
11801195
emitCellLanguageChange(event: vscode.NotebookCellLanguageChangeEvent): void {
11811196
that._onDidChangeCellLanguage.fire(event);
1182-
}
1197+
},
1198+
emitCellMetadataChange(event: vscode.NotebookCellMetadataChangeEvent): void {
1199+
that._onDidChangeCellMetadata.fire(event);
1200+
},
11831201
}, viewType, revivedUri, this, storageRoot);
11841202
this._unInitializedDocuments.set(revivedUri.toString(), document);
11851203
}
@@ -1424,7 +1442,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
14241442
const document = this._documents.get(URI.revive(uriComponents).toString());
14251443

14261444
if (document) {
1427-
document.accpetModelChanged(event);
1445+
document.acceptModelChanged(event);
14281446
}
14291447
}
14301448

@@ -1538,6 +1556,9 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
15381556
},
15391557
emitCellLanguageChange(event: vscode.NotebookCellLanguageChangeEvent): void {
15401558
that._onDidChangeCellLanguage.fire(event);
1559+
},
1560+
emitCellMetadataChange(event: vscode.NotebookCellMetadataChangeEvent): void {
1561+
that._onDidChangeCellMetadata.fire(event);
15411562
}
15421563
}, viewType, revivedUri, this, storageRoot);
15431564

@@ -1549,7 +1570,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
15491570
};
15501571
}
15511572

1552-
document.accpetModelChanged({
1573+
document.acceptModelChanged({
15531574
kind: NotebookCellsChangeType.Initialize,
15541575
versionId: modelData.versionId,
15551576
changes: [[

src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { InputFocusedContext, InputFocusedContextKey } from 'vs/platform/context
1717
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
1818
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
1919
import { IQuickInputService, IQuickPickItem, QuickPickInput } from 'vs/platform/quickinput/common/quickInput';
20-
import { BaseCellRenderTemplate, CellCollapseState, CellEditState, CellFocusMode, ICellViewModel, INotebookEditor, NOTEBOOK_CELL_INPUT_COLLAPSED, NOTEBOOK_CELL_EDITABLE, NOTEBOOK_CELL_HAS_OUTPUTS, NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, NOTEBOOK_CELL_OUTPUT_COLLAPSED, NOTEBOOK_CELL_TYPE, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_EDITOR_EXECUTING_NOTEBOOK, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_RUNNABLE, NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_OUTPUT_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
20+
import { BaseCellRenderTemplate, CellEditState, CellFocusMode, ICellViewModel, INotebookEditor, NOTEBOOK_CELL_INPUT_COLLAPSED, NOTEBOOK_CELL_EDITABLE, NOTEBOOK_CELL_HAS_OUTPUTS, NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, NOTEBOOK_CELL_OUTPUT_COLLAPSED, NOTEBOOK_CELL_TYPE, NOTEBOOK_EDITOR_EDITABLE, NOTEBOOK_EDITOR_EXECUTING_NOTEBOOK, NOTEBOOK_EDITOR_FOCUSED, NOTEBOOK_EDITOR_RUNNABLE, NOTEBOOK_IS_ACTIVE_EDITOR, NOTEBOOK_OUTPUT_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
2121
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel';
2222
import { CellKind, CellUri, NotebookCellRunState, NOTEBOOK_EDITOR_CURSOR_BOUNDARY } from 'vs/workbench/contrib/notebook/common/notebookCommon';
2323
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
@@ -1314,7 +1314,7 @@ registerAction2(class extends NotebookCellAction {
13141314
}
13151315

13161316
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
1317-
context.cell.collapseState = CellCollapseState.Collapsed;
1317+
context.notebookEditor.viewModel!.notebookDocument.changeCellMetadata(context.cell.handle, { inputCollapsed: true });
13181318
}
13191319
});
13201320

@@ -1337,7 +1337,7 @@ registerAction2(class extends NotebookCellAction {
13371337
}
13381338

13391339
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
1340-
context.cell.collapseState = CellCollapseState.Normal;
1340+
context.notebookEditor.viewModel!.notebookDocument.changeCellMetadata(context.cell.handle, { inputCollapsed: false });
13411341
}
13421342
});
13431343

@@ -1360,7 +1360,7 @@ registerAction2(class extends NotebookCellAction {
13601360
}
13611361

13621362
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
1363-
context.cell.outputCollapseState = CellCollapseState.Collapsed;
1363+
context.notebookEditor.viewModel!.notebookDocument.changeCellMetadata(context.cell.handle, { outputCollapsed: true });
13641364
}
13651365
});
13661366

@@ -1383,6 +1383,6 @@ registerAction2(class extends NotebookCellAction {
13831383
}
13841384

13851385
async runWithContext(accessor: ServicesAccessor, context: INotebookCellActionContext): Promise<void> {
1386-
context.cell.outputCollapseState = CellCollapseState.Normal;
1386+
context.notebookEditor.viewModel!.notebookDocument.changeCellMetadata(context.cell.handle, { inputCollapsed: false });
13871387
}
13881388
});

src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ export interface ICellViewModel {
113113
readonly model: NotebookCellTextModel;
114114
readonly id: string;
115115
readonly textBuffer: IReadonlyTextBuffer;
116-
collapseState: CellCollapseState;
117-
outputCollapseState: CellCollapseState;
118116
dragging: boolean;
119117
handle: number;
120118
uri: URI;
@@ -547,11 +545,6 @@ export enum CellEditState {
547545
Editing
548546
}
549547

550-
export enum CellCollapseState {
551-
Normal,
552-
Collapsed
553-
}
554-
555548
export enum CellFocusMode {
556549
Container,
557550
Editor

src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import * as UUID from 'vs/base/common/uuid';
1414
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
1515
import { IOpenerService, matchesScheme } from 'vs/platform/opener/common/opener';
1616
import { CELL_MARGIN, CELL_RUN_GUTTER, CODE_CELL_LEFT_MARGIN, CELL_OUTPUT_PADDING } from 'vs/workbench/contrib/notebook/browser/constants';
17-
import { CellCollapseState, INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
17+
import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
1818
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
1919
import { CellOutputKind, IProcessedOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon';
2020
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
@@ -561,7 +561,7 @@ ${loaderJs}
561561
return;
562562
}
563563

564-
if (cell.outputCollapseState === CellCollapseState.Collapsed) {
564+
if (cell.metadata?.outputCollapsed) {
565565
return false;
566566
}
567567

src/vs/workbench/contrib/notebook/browser/view/renderers/cellContextKeys.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
77
import { INotebookTextModel, NotebookCellRunState } from 'vs/workbench/contrib/notebook/common/notebookCommon';
88
import { BaseCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel';
9-
import { NOTEBOOK_CELL_TYPE, NOTEBOOK_VIEW_TYPE, NOTEBOOK_CELL_EDITABLE, NOTEBOOK_CELL_RUNNABLE, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, NOTEBOOK_CELL_RUN_STATE, NOTEBOOK_CELL_HAS_OUTPUTS, CellViewModelStateChangeEvent, CellEditState, NOTEBOOK_CELL_INPUT_COLLAPSED, CellCollapseState, NOTEBOOK_CELL_OUTPUT_COLLAPSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
9+
import { NOTEBOOK_CELL_TYPE, NOTEBOOK_VIEW_TYPE, NOTEBOOK_CELL_EDITABLE, NOTEBOOK_CELL_RUNNABLE, NOTEBOOK_CELL_MARKDOWN_EDIT_MODE, NOTEBOOK_CELL_RUN_STATE, NOTEBOOK_CELL_HAS_OUTPUTS, CellViewModelStateChangeEvent, CellEditState, NOTEBOOK_CELL_INPUT_COLLAPSED, NOTEBOOK_CELL_OUTPUT_COLLAPSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
1010
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
1111
import { MarkdownCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel';
1212
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
@@ -109,8 +109,8 @@ export class CellContextKeyManager extends Disposable {
109109
}
110110

111111
private updateForCollapseState() {
112-
this.cellContentCollapsed.set(this.element.collapseState === CellCollapseState.Collapsed);
113-
this.cellOutputCollapsed.set(this.element.outputCollapseState === CellCollapseState.Collapsed);
112+
this.cellContentCollapsed.set(!!this.element.metadata?.inputCollapsed);
113+
this.cellOutputCollapsed.set(!!this.element.metadata?.outputCollapsed);
114114
}
115115

116116
private updateForOutputs() {

src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
3838
import { INotificationService } from 'vs/platform/notification/common/notification';
3939
import { BOTTOM_CELL_TOOLBAR_HEIGHT, CELL_BOTTOM_MARGIN, CELL_TOP_MARGIN, EDITOR_BOTTOM_PADDING, EDITOR_TOOLBAR_HEIGHT, EDITOR_TOP_PADDING } from 'vs/workbench/contrib/notebook/browser/constants';
4040
import { CancelCellAction, ChangeCellLanguageAction, ExecuteCellAction, INotebookCellActionContext } from 'vs/workbench/contrib/notebook/browser/contrib/coreActions';
41-
import { BaseCellRenderTemplate, CellCollapseState, CellEditState, CodeCellRenderTemplate, ICellViewModel, INotebookCellList, INotebookEditor, isCodeCellRenderTemplate, MarkdownCellRenderTemplate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
41+
import { BaseCellRenderTemplate, CellEditState, CodeCellRenderTemplate, ICellViewModel, INotebookCellList, INotebookEditor, isCodeCellRenderTemplate, MarkdownCellRenderTemplate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
4242
import { CellContextKeyManager } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellContextKeys';
4343
import { CellMenus } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellMenus';
4444
import { CodeCell } from 'vs/workbench/contrib/notebook/browser/view/renderers/codeCell';
@@ -317,10 +317,10 @@ abstract class AbstractCellRenderer {
317317
return;
318318
}
319319

320-
if (templateData.currentRenderedCell.collapseState === CellCollapseState.Collapsed) {
321-
templateData.currentRenderedCell.collapseState = CellCollapseState.Normal;
322-
} else if (templateData.currentRenderedCell.outputCollapseState === CellCollapseState.Collapsed) {
323-
templateData.currentRenderedCell.outputCollapseState = CellCollapseState.Normal;
320+
if (templateData.currentRenderedCell.metadata?.inputCollapsed) {
321+
this.notebookEditor.viewModel!.notebookDocument.changeCellMetadata(templateData.currentRenderedCell.handle, { inputCollapsed: false });
322+
} else if (templateData.currentRenderedCell.metadata?.outputCollapsed) {
323+
this.notebookEditor.viewModel!.notebookDocument.changeCellMetadata(templateData.currentRenderedCell.handle, { outputCollapsed: false });
324324
}
325325
}));
326326
}

src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
1111
import * as nls from 'vs/nls';
1212
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
1313
import { EDITOR_BOTTOM_PADDING, EDITOR_TOP_PADDING } from 'vs/workbench/contrib/notebook/browser/constants';
14-
import { CellCollapseState, CellFocusMode, CodeCellRenderTemplate, INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
14+
import { CellFocusMode, CodeCellRenderTemplate, INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
1515
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService';
1616
import { getResizesObserver } from 'vs/workbench/contrib/notebook/browser/view/renderers/sizeObserver';
1717
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
@@ -305,11 +305,11 @@ export class CodeCell extends Disposable {
305305
}
306306

307307
private viewUpdate(): void {
308-
if (this.viewCell.collapseState === CellCollapseState.Collapsed && this.viewCell.outputCollapseState === CellCollapseState.Collapsed) {
308+
if (this.viewCell.metadata?.inputCollapsed && this.viewCell.metadata.outputCollapsed) {
309309
this.viewUpdateAllCollapsed();
310-
} else if (this.viewCell.collapseState === CellCollapseState.Collapsed) {
310+
} else if (this.viewCell.metadata?.inputCollapsed) {
311311
this.viewUpdateInputCollapsed();
312-
} else if (this.viewCell.outputCollapseState === CellCollapseState.Collapsed && this.viewCell.outputs.length) {
312+
} else if (this.viewCell.metadata?.outputCollapsed && this.viewCell.outputs.length) {
313313
this.viewUpdateOutputCollapsed();
314314
} else {
315315
this.viewUpdateExpanded();

src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
1212
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
1313
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1414
import { EDITOR_BOTTOM_PADDING, EDITOR_TOP_PADDING } from 'vs/workbench/contrib/notebook/browser/constants';
15-
import { CellEditState, CellFocusMode, INotebookEditor, MarkdownCellRenderTemplate, ICellViewModel, CellCollapseState } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
15+
import { CellEditState, CellFocusMode, INotebookEditor, MarkdownCellRenderTemplate, ICellViewModel } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
1616
import { CellFoldingState } from 'vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel';
1717
import { MarkdownCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel';
1818
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
@@ -132,7 +132,7 @@ export class StatefulMarkdownCell extends Disposable {
132132
}
133133

134134
private viewUpdate(): void {
135-
if (this.viewCell.collapseState === CellCollapseState.Collapsed) {
135+
if (this.viewCell.metadata?.inputCollapsed) {
136136
this.viewUpdateCollapsed();
137137
} else if (this.viewCell.editState === CellEditState.Editing) {
138138
this.viewUpdateEditing();

0 commit comments

Comments
 (0)