From a7d5ca7e7d5d97e6cefa9fc9f4d16950829bdfd7 Mon Sep 17 00:00:00 2001 From: Michael Lively Date: Wed, 18 Dec 2024 14:12:51 -0800 Subject: [PATCH] Fix logic for notebook outline data source isEmpty() fn (#236525) amend logic for notebook outline data source isEmpty() --- .../contrib/outline/notebookOutline.ts | 61 ++++++++++++------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.ts b/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.ts index 7df78960c43d4..0e3812f9f8be6 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.ts @@ -346,6 +346,28 @@ export class NotebookQuickPickProvider implements IQuickPickDataSource NotebookOutlineConstants.NonHeaderOutlineLevel) // show symbols off + cell is code + is level >7 (nb symbol levels) + ) { + return true; + } + + return false; +} + export class NotebookOutlinePaneProvider implements IDataSource { private readonly _disposables = new DisposableStore(); @@ -381,14 +403,14 @@ export class NotebookOutlinePaneProvider implements IDataSource NotebookOutlineConstants.NonHeaderOutlineLevel) // show symbols off + cell is code + is level >7 (nb symbol levels) - ) { - return true; - } - - return false; - } - *getChildren(element: NotebookCellOutline | OutlineEntry): Iterable { const isOutline = element instanceof NotebookCellOutline; const entries = isOutline ? this.outlineDataSourceRef?.object?.entries ?? [] : element.children; @@ -518,7 +521,9 @@ export class NotebookCellOutline implements IOutline { private _breadcrumbsDataSource!: IBreadcrumbsDataSource; // view settings + private outlineShowCodeCells: boolean; private outlineShowCodeCellSymbols: boolean; + private outlineShowMarkdownHeadersOnly: boolean; // getters get activeElement(): OutlineEntry | undefined { @@ -538,7 +543,13 @@ export class NotebookCellOutline implements IOutline { return this._outlineDataSourceReference?.object?.uri; } get isEmpty(): boolean { - return this._outlineDataSourceReference?.object?.isEmpty ?? true; + if (!this._outlineDataSourceReference?.object?.entries) { + return true; + } + + return !this._outlineDataSourceReference.object.entries.some(entry => { + return !filterEntry(entry, this.outlineShowMarkdownHeadersOnly, this.outlineShowCodeCells, this.outlineShowCodeCellSymbols); + }); } private checkDelayer() { @@ -558,7 +569,9 @@ export class NotebookCellOutline implements IOutline { @ILanguageFeaturesService private readonly _languageFeaturesService: ILanguageFeaturesService, @INotebookExecutionStateService private readonly _notebookExecutionStateService: INotebookExecutionStateService, ) { + this.outlineShowCodeCells = this._configurationService.getValue(NotebookSetting.outlineShowCodeCells); this.outlineShowCodeCellSymbols = this._configurationService.getValue(NotebookSetting.outlineShowCodeCellSymbols); + this.outlineShowMarkdownHeadersOnly = this._configurationService.getValue(NotebookSetting.outlineShowMarkdownHeadersOnly); this.initializeOutline(); @@ -615,6 +628,10 @@ export class NotebookCellOutline implements IOutline { e.affectsConfiguration(NotebookSetting.outlineShowCodeCellSymbols) || e.affectsConfiguration(NotebookSetting.breadcrumbsShowCodeCells) ) { + this.outlineShowCodeCells = this._configurationService.getValue(NotebookSetting.outlineShowCodeCells); + this.outlineShowCodeCellSymbols = this._configurationService.getValue(NotebookSetting.outlineShowCodeCellSymbols); + this.outlineShowMarkdownHeadersOnly = this._configurationService.getValue(NotebookSetting.outlineShowMarkdownHeadersOnly); + this.delayedRecomputeState(); } }));