@@ -106,14 +106,16 @@ class NotebookOutlineRenderer implements ITreeRenderer<OutlineEntry, FuzzyScore,
106106 } ;
107107
108108 const isCodeCell = node . element . cell . cellKind === CellKind . Code ;
109- if ( isCodeCell && this . _themeService . getFileIconTheme ( ) . hasFileIcons && ! node . element . isExecuting ) {
109+ if ( node . element . level >= 8 ) { // symbol
110+ template . iconClass . className = 'element-icon ' + ThemeIcon . asClassNameArray ( node . element . icon ) . join ( ' ' ) ;
111+ } else if ( isCodeCell && this . _themeService . getFileIconTheme ( ) . hasFileIcons && ! node . element . isExecuting ) {
110112 template . iconClass . className = '' ;
111113 extraClasses . push ( ...getIconClassesForLanguageId ( node . element . cell . language ?? '' ) ) ;
112114 } else {
113115 template . iconClass . className = 'element-icon ' + ThemeIcon . asClassNameArray ( node . element . icon ) . join ( ' ' ) ;
114116 }
115117
116- template . iconLabel . setLabel ( node . element . label , undefined , options ) ;
118+ template . iconLabel . setLabel ( ' ' + node . element . label , undefined , options ) ;
117119
118120 const { markerInfo } = node . element ;
119121
@@ -377,7 +379,11 @@ export class NotebookCellOutline implements IOutline<OutlineEntry> {
377379 } ) ) ;
378380
379381 installSelectionListener ( ) ;
380- const treeDataSource : IDataSource < this, OutlineEntry > = { getChildren : parent => parent instanceof NotebookCellOutline ? ( this . _outlineProvider ?. entries ?? [ ] ) : parent . children } ;
382+ const treeDataSource : IDataSource < this, OutlineEntry > = {
383+ getChildren : parent => {
384+ return this . getChildren ( parent , _configurationService ) ;
385+ }
386+ } ;
381387 const delegate = new NotebookOutlineVirtualDelegate ( ) ;
382388 const renderers = [ instantiationService . createInstance ( NotebookOutlineRenderer , this . _editor . getControl ( ) , _target ) ] ;
383389 const comparator = new NotebookComparator ( ) ;
@@ -412,6 +418,29 @@ export class NotebookCellOutline implements IOutline<OutlineEntry> {
412418 } ;
413419 }
414420
421+ * getChildren ( parent : OutlineEntry | NotebookCellOutline , configurationService : IConfigurationService ) : Iterable < OutlineEntry > {
422+ const showCodeCells = configurationService . getValue < boolean > ( NotebookSetting . outlineShowCodeCells ) ;
423+ const showCodeCellSymbols = configurationService . getValue < boolean > ( NotebookSetting . outlineShowCodeCellSymbols ) ;
424+ const showMarkdownHeadersOnly = configurationService . getValue < boolean > ( NotebookSetting . outlineShowMarkdownHeadersOnly ) ;
425+
426+ for ( const entry of parent instanceof NotebookCellOutline ? ( this . _outlineProvider ?. entries ?? [ ] ) : parent . children ) {
427+ if ( entry . cell . cellKind === CellKind . Markup ) {
428+ if ( ! showMarkdownHeadersOnly ) {
429+ yield entry ;
430+ } else if ( entry . level < 7 ) {
431+ yield entry ;
432+ }
433+
434+ } else if ( showCodeCells && entry . cell . cellKind === CellKind . Code ) {
435+ if ( showCodeCellSymbols ) {
436+ yield entry ;
437+ } else if ( entry . level === 7 ) {
438+ yield entry ;
439+ }
440+ }
441+ }
442+ }
443+
415444 async setFullSymbols ( cancelToken : CancellationToken ) {
416445 await this . _outlineProvider ?. setFullSymbols ( cancelToken ) ;
417446 }
@@ -524,10 +553,14 @@ export class NotebookOutlineCreator implements IOutlineCreator<NotebookEditor, O
524553 async createOutline ( editor : NotebookEditor , target : OutlineTarget , cancelToken : CancellationToken ) : Promise < IOutline < OutlineEntry > | undefined > {
525554 const outline = this . _instantiationService . createInstance ( NotebookCellOutline , editor , target ) ;
526555
527- const showAllSymbols = this . _configurationService . getValue < boolean > ( NotebookSetting . gotoSymbolsAllSymbols ) ;
528- if ( target === OutlineTarget . QuickPick && showAllSymbols ) {
556+ const showAllGotoSymbols = this . _configurationService . getValue < boolean > ( NotebookSetting . gotoSymbolsAllSymbols ) ;
557+ const showAllOutlineSymbols = this . _configurationService . getValue < boolean > ( NotebookSetting . outlineShowCodeCellSymbols ) ;
558+ if ( target === OutlineTarget . QuickPick && showAllGotoSymbols ) {
559+ await outline . setFullSymbols ( cancelToken ) ;
560+ } else if ( target === OutlineTarget . OutlinePane && showAllOutlineSymbols ) {
529561 await outline . setFullSymbols ( cancelToken ) ;
530562 }
563+
531564 return outline ;
532565 }
533566}
@@ -547,25 +580,30 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
547580 order : 100 ,
548581 type : 'object' ,
549582 'properties' : {
550- 'notebook.outline.showCodeCells' : {
583+ [ NotebookSetting . outlineShowMarkdownHeadersOnly ] : {
551584 type : 'boolean' ,
552- default : false ,
553- markdownDescription : localize ( 'outline.showCodeCells ' , "When enabled notebook outline shows code cells." )
585+ default : true ,
586+ markdownDescription : localize ( 'outline.showMarkdownHeadersOnly ' , "When enabled, notebook outline will show only markdown cells containing a header ." )
554587 } ,
555- 'notebook.outline.showNonHeaderMarkdownCells' : {
588+ [ NotebookSetting . outlineShowCodeCells ] : {
556589 type : 'boolean' ,
557590 default : false ,
558- markdownDescription : localize ( 'outline.showNonHeaderMarkdownCells' , "When enabled, notebook outline will show non-header markdown cell entries. When disabled, only markdown cells containing a header are shown." )
591+ markdownDescription : localize ( 'outline.showCodeCells' , "When enabled, notebook outline shows code cells." )
592+ } ,
593+ [ NotebookSetting . outlineShowCodeCellSymbols ] : {
594+ type : 'boolean' ,
595+ default : true ,
596+ markdownDescription : localize ( 'outline.showCodeCellSymbols' , "When enabled, notebook outline shows code cell symbols. Relies on `notebook.outline.showCodeCells` being enabled." )
559597 } ,
560- 'notebook.breadcrumbs.showCodeCells' : {
598+ [ NotebookSetting . breadcrumbsShowCodeCells ] : {
561599 type : 'boolean' ,
562600 default : true ,
563- markdownDescription : localize ( 'breadcrumbs.showCodeCells' , "When enabled notebook breadcrumbs contain code cells." )
601+ markdownDescription : localize ( 'breadcrumbs.showCodeCells' , "When enabled, notebook breadcrumbs contain code cells." )
564602 } ,
565603 [ NotebookSetting . gotoSymbolsAllSymbols ] : {
566604 type : 'boolean' ,
567605 default : true ,
568- markdownDescription : localize ( 'notebook.gotoSymbols.showAllSymbols' , "When enabled the Go to Symbol Quick Pick will display full code symbols from the notebook, as well as Markdown headers." )
606+ markdownDescription : localize ( 'notebook.gotoSymbols.showAllSymbols' , "When enabled, the Go to Symbol Quick Pick will display full code symbols from the notebook, as well as Markdown headers." )
569607 } ,
570608 }
571609} ) ;
@@ -579,48 +617,74 @@ MenuRegistry.appendMenuItem(MenuId.ViewTitle, {
579617 when : ContextKeyExpr . and ( ContextKeyExpr . equals ( 'view' , IOutlinePane . Id ) , NOTEBOOK_IS_ACTIVE_EDITOR ) ,
580618} ) ;
581619
620+ registerAction2 ( class ToggleShowMarkdownHeadersOnly extends Action2 {
621+ constructor ( ) {
622+ super ( {
623+ id : 'notebook.outline.toggleShowMarkdownHeadersOnly' ,
624+ title : localize ( 'toggleShowMarkdownHeadersOnly' , "Markdown Headers Only" ) ,
625+ f1 : false ,
626+ toggled : {
627+ condition : ContextKeyExpr . equals ( 'config.notebook.outline.showMarkdownHeadersOnly' , true )
628+ } ,
629+ menu : {
630+ id : MenuId . NotebookOutlineFilter ,
631+ group : '0_markdown_cells' ,
632+ }
633+ } ) ;
634+ }
635+
636+ run ( accessor : ServicesAccessor , ...args : any [ ] ) {
637+ const configurationService = accessor . get ( IConfigurationService ) ;
638+ const showMarkdownHeadersOnly = configurationService . getValue < boolean > ( NotebookSetting . outlineShowMarkdownHeadersOnly ) ;
639+ configurationService . updateValue ( NotebookSetting . outlineShowMarkdownHeadersOnly , ! showMarkdownHeadersOnly ) ;
640+ }
641+ } ) ;
642+
643+
582644registerAction2 ( class ToggleCodeCellEntries extends Action2 {
583645 constructor ( ) {
584646 super ( {
585647 id : 'notebook.outline.toggleCodeCells' ,
586- title : localize ( 'toggleCodeCells' , "Toggle Code Cells" ) ,
648+ title : localize ( 'toggleCodeCells' , "Code Cells" ) ,
587649 f1 : false ,
588650 toggled : {
589651 condition : ContextKeyExpr . equals ( 'config.notebook.outline.showCodeCells' , true )
590652 } ,
591653 menu : {
592654 id : MenuId . NotebookOutlineFilter ,
593- group : 'filter' ,
655+ order : 1 ,
656+ group : '1_code_cells' ,
594657 }
595658 } ) ;
596659 }
597660
598661 run ( accessor : ServicesAccessor , ...args : any [ ] ) {
599662 const configurationService = accessor . get ( IConfigurationService ) ;
600- const showCodeCells = configurationService . getValue < boolean > ( 'notebook.outline.showCodeCells' ) ;
601- configurationService . updateValue ( 'notebook.outline.showCodeCells' , ! showCodeCells ) ;
663+ const showCodeCells = configurationService . getValue < boolean > ( NotebookSetting . outlineShowCodeCells ) ;
664+ configurationService . updateValue ( NotebookSetting . outlineShowCodeCells , ! showCodeCells ) ;
602665 }
603666} ) ;
604667
605- registerAction2 ( class ToggleNonHeaderMarkdownCells extends Action2 {
668+ registerAction2 ( class ToggleCodeCellSymbolEntries extends Action2 {
606669 constructor ( ) {
607670 super ( {
608- id : 'notebook.outline.toggleNonHeaderMarkdownCells ' ,
609- title : localize ( 'toggleNonHeaderMarkdownCells ' , "Toggle Non-Header Markdown Cells " ) ,
671+ id : 'notebook.outline.toggleCodeCellSymbols ' ,
672+ title : localize ( 'toggleCodeCellSymbols ' , "Code Cell Symbols " ) ,
610673 f1 : false ,
611674 toggled : {
612- condition : ContextKeyExpr . equals ( 'config.notebook.outline.showNonHeaderMarkdownCells ' , true )
675+ condition : ContextKeyExpr . equals ( 'config.notebook.outline.showCodeCellSymbols ' , true )
613676 } ,
614677 menu : {
615678 id : MenuId . NotebookOutlineFilter ,
616- group : 'filter' ,
679+ order : 2 ,
680+ group : '1_code_cells' ,
617681 }
618682 } ) ;
619683 }
620684
621685 run ( accessor : ServicesAccessor , ...args : any [ ] ) {
622686 const configurationService = accessor . get ( IConfigurationService ) ;
623- const showNonHeaderMarkdownCells = configurationService . getValue < boolean > ( 'notebook.outline.showNonHeaderMarkdownCells' ) ;
624- configurationService . updateValue ( 'notebook.outline.showNonHeaderMarkdownCells' , ! showNonHeaderMarkdownCells ) ;
687+ const showCodeCellSymbols = configurationService . getValue < boolean > ( NotebookSetting . outlineShowCodeCellSymbols ) ;
688+ configurationService . updateValue ( NotebookSetting . outlineShowCodeCellSymbols , ! showCodeCellSymbols ) ;
625689 }
626690} ) ;
0 commit comments