@@ -45,7 +45,7 @@ export class StickyLineCandidateProvider extends Disposable {
45
45
private _outlineModel : StickyOutlineElement | undefined ;
46
46
private readonly _sessionStore : DisposableStore = new DisposableStore ( ) ;
47
47
private _modelVersionId : number = 0 ;
48
- private _providerID : string = '' ;
48
+ private _providerID : string | undefined = undefined ;
49
49
50
50
constructor (
51
51
editor : ICodeEditor ,
@@ -70,13 +70,13 @@ export class StickyLineCandidateProvider extends Disposable {
70
70
return ;
71
71
} else {
72
72
this . _sessionStore . add ( this . _editor . onDidChangeModel ( ( ) => {
73
- this . _providerID = '' ;
73
+ this . _providerID = undefined ;
74
74
this . update ( ) ;
75
75
} ) ) ;
76
76
this . _sessionStore . add ( this . _editor . onDidChangeHiddenAreas ( ( ) => this . update ( ) ) ) ;
77
77
this . _sessionStore . add ( this . _editor . onDidChangeModelContent ( ( ) => this . _updateSoon . schedule ( ) ) ) ;
78
78
this . _sessionStore . add ( this . _languageFeaturesService . documentSymbolProvider . onDidChange ( ( ) => {
79
- this . _providerID = '' ;
79
+ this . _providerID = undefined ;
80
80
this . update ( ) ;
81
81
} ) ) ;
82
82
this . update ( ) ;
@@ -214,15 +214,15 @@ class StickyOutlineElement {
214
214
return new StickyOutlineElement ( range , children , undefined ) ;
215
215
}
216
216
217
- public static fromOutlineModel ( outlineModel : OutlineModel , providerID : string ) : { stickyOutlineElement : StickyOutlineElement ; providerID : string } {
217
+ public static fromOutlineModel ( outlineModel : OutlineModel , providerID : string | undefined ) : { stickyOutlineElement : StickyOutlineElement ; providerID : string | undefined } {
218
218
219
- let ID : string = providerID ;
219
+ let ID : string | undefined = providerID ;
220
220
let outlineElements : Map < string , OutlineElement > ;
221
221
// When several possible outline providers
222
- if ( outlineModel . children . size !== 0 && Iterable . first ( outlineModel . children . values ( ) ) instanceof OutlineGroup ) {
223
- const filteredProviders = Array . from ( outlineModel . children . values ( ) ) . filter ( outlineGroupOfModel => outlineGroupOfModel . id === providerID ) ;
224
- if ( filteredProviders && filteredProviders . length !== 0 ) {
225
- outlineElements = filteredProviders [ 0 ] . children ;
222
+ if ( Iterable . first ( outlineModel . children . values ( ) ) instanceof OutlineGroup ) {
223
+ const provider = Iterable . find ( outlineModel . children . values ( ) , outlineGroupOfModel => outlineGroupOfModel . id === providerID ) ;
224
+ if ( provider ) {
225
+ outlineElements = provider . children ;
226
226
} else {
227
227
let tempID = '' ;
228
228
let maxTotalSumOfRanges = 0 ;
@@ -236,7 +236,7 @@ class StickyOutlineElement {
236
236
}
237
237
}
238
238
ID = tempID ;
239
- outlineElements = optimalOutlineGroup ? .children as Map < string , OutlineElement > ;
239
+ outlineElements = optimalOutlineGroup ! . children ;
240
240
}
241
241
} else {
242
242
outlineElements = outlineModel . children as Map < string , OutlineElement > ;
0 commit comments