@@ -128,7 +128,7 @@ class OutlineModel extends QuickOpenModel {
128128
129129 // Update previous result with count
130130 if ( currentResult ) {
131- currentResult . setGroupLabel ( this . renderGroupLabel ( currentType , typeCounter ) ) ;
131+ currentResult . setGroupLabel ( typeof currentType === 'number' ? this . renderGroupLabel ( currentType , typeCounter ) : undefined ) ;
132132 }
133133
134134 currentType = result . getKind ( ) ;
@@ -146,7 +146,7 @@ class OutlineModel extends QuickOpenModel {
146146
147147 // Update previous result with count
148148 if ( currentResult ) {
149- currentResult . setGroupLabel ( this . renderGroupLabel ( currentType , typeCounter ) ) ;
149+ currentResult . setGroupLabel ( typeof currentType === 'number' ? this . renderGroupLabel ( currentType , typeCounter ) : undefined ) ;
150150 }
151151 }
152152
@@ -338,7 +338,7 @@ class SymbolEntry extends EditorQuickOpenEntryGroup {
338338
339339 // Decorate if possible
340340 if ( types . isFunction ( activeTextEditorWidget . changeDecorations ) ) {
341- this . handler . decorateOutline ( this . range , range , activeTextEditorWidget , this . editorService . activeControl . group ) ;
341+ this . handler . decorateOutline ( this . range , range , activeTextEditorWidget , this . editorService . activeControl . group ! ) ;
342342 }
343343 }
344344
@@ -365,11 +365,11 @@ export class GotoSymbolHandler extends QuickOpenHandler {
365365
366366 static readonly ID = 'workbench.picker.filesymbols' ;
367367
368- private rangeHighlightDecorationId : IEditorLineDecoration ;
369- private lastKnownEditorViewState : IEditorViewState ;
368+ private rangeHighlightDecorationId ? : IEditorLineDecoration ;
369+ private lastKnownEditorViewState : IEditorViewState | null ;
370370
371- private cachedOutlineRequest : Promise < OutlineModel > ;
372- private pendingOutlineRequest : CancellationTokenSource ;
371+ private cachedOutlineRequest ? : Promise < OutlineModel | null > ;
372+ private pendingOutlineRequest ? : CancellationTokenSource ;
373373
374374 constructor (
375375 @IEditorService private readonly editorService : IEditorService
@@ -386,11 +386,11 @@ export class GotoSymbolHandler extends QuickOpenHandler {
386386 private onDidActiveEditorChange ( ) : void {
387387 this . clearOutlineRequest ( ) ;
388388
389- this . lastKnownEditorViewState = undefined ;
389+ this . lastKnownEditorViewState = null ;
390390 this . rangeHighlightDecorationId = undefined ;
391391 }
392392
393- getResults ( searchValue : string , token : CancellationToken ) : Promise < QuickOpenModel > {
393+ getResults ( searchValue : string , token : CancellationToken ) : Promise < QuickOpenModel | null > {
394394 searchValue = searchValue . trim ( ) ;
395395
396396 // Support to cancel pending outline requests
@@ -406,6 +406,10 @@ export class GotoSymbolHandler extends QuickOpenHandler {
406406
407407 // Resolve Outline Model
408408 return this . getOutline ( ) . then ( outline => {
409+ if ( ! outline ) {
410+ return outline ;
411+ }
412+
409413 if ( token . isCancellationRequested ) {
410414 return outline ;
411415 }
@@ -469,20 +473,20 @@ export class GotoSymbolHandler extends QuickOpenHandler {
469473 const label = strings . trim ( element . name ) ;
470474
471475 // Show parent scope as description
472- const description : string = element . containerName ;
476+ const description = element . containerName || '' ;
473477 const icon = symbolKindToCssClass ( element . kind ) ;
474478
475479 // Add
476480 results . push ( new SymbolEntry ( i ,
477481 label , element . kind , description , `symbol-icon ${ icon } ` ,
478- element . range , element . selectionRange , null , this . editorService , this
482+ element . range , element . selectionRange , [ ] , this . editorService , this
479483 ) ) ;
480484 }
481485
482486 return results ;
483487 }
484488
485- private getOutline ( ) : Promise < OutlineModel > {
489+ private getOutline ( ) : Promise < OutlineModel | null > {
486490 if ( ! this . cachedOutlineRequest ) {
487491 this . cachedOutlineRequest = this . doGetActiveOutline ( ) ;
488492 }
@@ -499,7 +503,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
499503 }
500504
501505 if ( model && types . isFunction ( ( < ITextModel > model ) . getLanguageIdentifier ) ) {
502- return Promise . resolve ( asPromise ( ( ) => getDocumentSymbols ( < ITextModel > model , true , this . pendingOutlineRequest . token ) ) . then ( entries => {
506+ return Promise . resolve ( asPromise ( ( ) => getDocumentSymbols ( < ITextModel > model , true , this . pendingOutlineRequest ! . token ) ) . then ( entries => {
503507 return new OutlineModel ( this . toQuickOpenEntries ( entries ) ) ;
504508 } ) ) ;
505509 }
@@ -515,7 +519,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
515519 if ( this . rangeHighlightDecorationId ) {
516520 deleteDecorations . push ( this . rangeHighlightDecorationId . lineDecorationId ) ;
517521 deleteDecorations . push ( this . rangeHighlightDecorationId . rangeHighlightId ) ;
518- this . rangeHighlightDecorationId = null ;
522+ this . rangeHighlightDecorationId = undefined ;
519523 }
520524
521525 const newDecorations : IModelDeltaDecoration [ ] = [
@@ -555,20 +559,21 @@ export class GotoSymbolHandler extends QuickOpenHandler {
555559 }
556560
557561 private clearDecorations ( ) : void {
558- if ( this . rangeHighlightDecorationId ) {
562+ const rangeHighlightDecorationId = this . rangeHighlightDecorationId ;
563+ if ( rangeHighlightDecorationId ) {
559564 this . editorService . visibleControls . forEach ( editor => {
560- if ( editor . group . id === this . rangeHighlightDecorationId . groupId ) {
565+ if ( editor . group && editor . group . id === rangeHighlightDecorationId . groupId ) {
561566 const editorControl = < IEditor > editor . getControl ( ) ;
562567 editorControl . changeDecorations ( ( changeAccessor : IModelDecorationsChangeAccessor ) => {
563568 changeAccessor . deltaDecorations ( [
564- this . rangeHighlightDecorationId . lineDecorationId ,
565- this . rangeHighlightDecorationId . rangeHighlightId
569+ rangeHighlightDecorationId . lineDecorationId ,
570+ rangeHighlightDecorationId . rangeHighlightId
566571 ] , [ ] ) ;
567572 } ) ;
568573 }
569574 } ) ;
570575
571- this . rangeHighlightDecorationId = null ;
576+ this . rangeHighlightDecorationId = undefined ;
572577 }
573578 }
574579
@@ -598,6 +603,6 @@ export class GotoSymbolHandler extends QuickOpenHandler {
598603 this . pendingOutlineRequest = undefined ;
599604 }
600605
601- this . cachedOutlineRequest = null ;
606+ this . cachedOutlineRequest = undefined ;
602607 }
603608}
0 commit comments