From c78b1d7c95df5443ef844ac8bc13124c79cca64c Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 13 May 2020 10:52:01 +0200 Subject: [PATCH] Notebook outline shows icons for markdown and code entries, #95234 --- .../codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts | 5 ++++- .../contrib/notebook/browser/contrib/toc/tocProvider.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts b/src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts index 43bfc92aa31..d23fc98c27e 100644 --- a/src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts +++ b/src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess.ts @@ -25,6 +25,7 @@ import { prepareQuery } from 'vs/base/common/fuzzyScorer'; import { SymbolKind } from 'vs/editor/common/modes'; import { fuzzyScore, createMatches } from 'vs/base/common/filters'; import { onUnexpectedError } from 'vs/base/common/errors'; +import { ThemeIcon } from 'vs/platform/theme/common/themeService'; export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccessProvider { @@ -133,7 +134,8 @@ export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccess kind: SymbolKind.File, index: idx, score: 0, - label: entry.label, + label: entry.icon ? `$(${entry.icon.id}) ${entry.label}` : entry.label, + ariaLabel: entry.detail ? `${entry.label}, ${entry.detail}` : entry.label, detail: entry.detail, description: entry.description, }; @@ -232,6 +234,7 @@ Registry.as(ActionExtensions.WorkbenchActions).registe //#region toc definition and logic export interface ITableOfContentsEntry { + icon?: ThemeIcon; label: string; detail?: string; description?: string; diff --git a/src/vs/workbench/contrib/notebook/browser/contrib/toc/tocProvider.ts b/src/vs/workbench/contrib/notebook/browser/contrib/toc/tocProvider.ts index d7305d9e53f..b71692f646e 100644 --- a/src/vs/workbench/contrib/notebook/browser/contrib/toc/tocProvider.ts +++ b/src/vs/workbench/contrib/notebook/browser/contrib/toc/tocProvider.ts @@ -6,7 +6,7 @@ import { TableOfContentsProviderRegistry, ITableOfContentsProvider, ITableOfContentsEntry } from 'vs/workbench/contrib/codeEditor/browser/quickaccess/gotoSymbolQuickAccess'; import { NotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookEditor'; import { CellKind } from 'vs/workbench/contrib/notebook/common/notebookCommon'; - +import { Codicon } from 'vs/base/common/codicons'; TableOfContentsProviderRegistry.register(NotebookEditor.ID, new class implements ITableOfContentsProvider { async provideTableOfContents(editor: NotebookEditor) { @@ -26,6 +26,7 @@ TableOfContentsProviderRegistry.register(NotebookEditor.ID, new class implements if (matches && matches.length) { for (let j = 0; j < matches.length; j++) { result.push({ + icon: cell.cellKind === CellKind.Markdown ? Codicon.markdown : Codicon.code, label: matches[j].replace(/^[ \t]*(\#+)/, ''), reveal: () => { editorWidget.revealInCenterIfOutsideViewport(cell); -- GitLab