@@ -106,14 +106,16 @@ class NotebookOutlineRenderer implements ITreeRenderer<OutlineEntry, FuzzyScore,
106
106
} ;
107
107
108
108
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 ) {
110
112
template . iconClass . className = '' ;
111
113
extraClasses . push ( ...getIconClassesForLanguageId ( node . element . cell . language ?? '' ) ) ;
112
114
} else {
113
115
template . iconClass . className = 'element-icon ' + ThemeIcon . asClassNameArray ( node . element . icon ) . join ( ' ' ) ;
114
116
}
115
117
116
- template . iconLabel . setLabel ( node . element . label , undefined , options ) ;
118
+ template . iconLabel . setLabel ( ' ' + node . element . label , undefined , options ) ;
117
119
118
120
const { markerInfo } = node . element ;
119
121
@@ -377,7 +379,11 @@ export class NotebookCellOutline implements IOutline<OutlineEntry> {
377
379
} ) ) ;
378
380
379
381
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
+ } ;
381
387
const delegate = new NotebookOutlineVirtualDelegate ( ) ;
382
388
const renderers = [ instantiationService . createInstance ( NotebookOutlineRenderer , this . _editor . getControl ( ) , _target ) ] ;
383
389
const comparator = new NotebookComparator ( ) ;
@@ -412,6 +418,29 @@ export class NotebookCellOutline implements IOutline<OutlineEntry> {
412
418
} ;
413
419
}
414
420
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
+
415
444
async setFullSymbols ( cancelToken : CancellationToken ) {
416
445
await this . _outlineProvider ?. setFullSymbols ( cancelToken ) ;
417
446
}
@@ -524,10 +553,14 @@ export class NotebookOutlineCreator implements IOutlineCreator<NotebookEditor, O
524
553
async createOutline ( editor : NotebookEditor , target : OutlineTarget , cancelToken : CancellationToken ) : Promise < IOutline < OutlineEntry > | undefined > {
525
554
const outline = this . _instantiationService . createInstance ( NotebookCellOutline , editor , target ) ;
526
555
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 ) {
529
561
await outline . setFullSymbols ( cancelToken ) ;
530
562
}
563
+
531
564
return outline ;
532
565
}
533
566
}
@@ -547,25 +580,30 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).regis
547
580
order : 100 ,
548
581
type : 'object' ,
549
582
'properties' : {
550
- 'notebook.outline.showCodeCells' : {
583
+ [ NotebookSetting . outlineShowMarkdownHeadersOnly ] : {
551
584
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 ." )
554
587
} ,
555
- 'notebook.outline.showNonHeaderMarkdownCells' : {
588
+ [ NotebookSetting . outlineShowCodeCells ] : {
556
589
type : 'boolean' ,
557
590
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." )
559
597
} ,
560
- 'notebook.breadcrumbs.showCodeCells' : {
598
+ [ NotebookSetting . breadcrumbsShowCodeCells ] : {
561
599
type : 'boolean' ,
562
600
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." )
564
602
} ,
565
603
[ NotebookSetting . gotoSymbolsAllSymbols ] : {
566
604
type : 'boolean' ,
567
605
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." )
569
607
} ,
570
608
}
571
609
} ) ;
@@ -579,48 +617,74 @@ MenuRegistry.appendMenuItem(MenuId.ViewTitle, {
579
617
when : ContextKeyExpr . and ( ContextKeyExpr . equals ( 'view' , IOutlinePane . Id ) , NOTEBOOK_IS_ACTIVE_EDITOR ) ,
580
618
} ) ;
581
619
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
+
582
644
registerAction2 ( class ToggleCodeCellEntries extends Action2 {
583
645
constructor ( ) {
584
646
super ( {
585
647
id : 'notebook.outline.toggleCodeCells' ,
586
- title : localize ( 'toggleCodeCells' , "Toggle Code Cells" ) ,
648
+ title : localize ( 'toggleCodeCells' , "Code Cells" ) ,
587
649
f1 : false ,
588
650
toggled : {
589
651
condition : ContextKeyExpr . equals ( 'config.notebook.outline.showCodeCells' , true )
590
652
} ,
591
653
menu : {
592
654
id : MenuId . NotebookOutlineFilter ,
593
- group : 'filter' ,
655
+ order : 1 ,
656
+ group : '1_code_cells' ,
594
657
}
595
658
} ) ;
596
659
}
597
660
598
661
run ( accessor : ServicesAccessor , ...args : any [ ] ) {
599
662
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 ) ;
602
665
}
603
666
} ) ;
604
667
605
- registerAction2 ( class ToggleNonHeaderMarkdownCells extends Action2 {
668
+ registerAction2 ( class ToggleCodeCellSymbolEntries extends Action2 {
606
669
constructor ( ) {
607
670
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 " ) ,
610
673
f1 : false ,
611
674
toggled : {
612
- condition : ContextKeyExpr . equals ( 'config.notebook.outline.showNonHeaderMarkdownCells ' , true )
675
+ condition : ContextKeyExpr . equals ( 'config.notebook.outline.showCodeCellSymbols ' , true )
613
676
} ,
614
677
menu : {
615
678
id : MenuId . NotebookOutlineFilter ,
616
- group : 'filter' ,
679
+ order : 2 ,
680
+ group : '1_code_cells' ,
617
681
}
618
682
} ) ;
619
683
}
620
684
621
685
run ( accessor : ServicesAccessor , ...args : any [ ] ) {
622
686
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 ) ;
625
689
}
626
690
} ) ;
0 commit comments