@@ -90,13 +90,10 @@ export class StickyLineCandidateProvider extends Disposable {
90
90
if ( this . _editor . hasModel ( ) ) {
91
91
const model = this . _editor . getModel ( ) ;
92
92
const modelVersionId = model . getVersionId ( ) ;
93
- console . log ( 'this._languageFeaturesService.documentSymbolProvider : ' , this . _languageFeaturesService . documentSymbolProvider ) ;
94
- // TODO: Actually I should probably check what method to choose in the constructor
95
93
const outlineModel = await OutlineModel . create ( this . _languageFeaturesService . documentSymbolProvider , model , token ) as OutlineModel ;
96
94
if ( token . isCancellationRequested ) {
97
95
return ;
98
96
}
99
- console . log ( 'outline model : ' , outlineModel ) ;
100
97
if ( outlineModel . children . size !== 0 ) {
101
98
this . _outlineModel = StickyOutlineElement . fromOutlineModel ( outlineModel ) ;
102
99
} else {
@@ -112,7 +109,6 @@ export class StickyLineCandidateProvider extends Disposable {
112
109
) ;
113
110
}
114
111
}
115
- console . log ( 'this._outlineModel : ' , this . _outlineModel ) ;
116
112
this . _modelVersionId = modelVersionId ;
117
113
}
118
114
}
@@ -212,21 +208,41 @@ class StickyOutlineElement {
212
208
const regions = foldingModel . getRegions ( ) ;
213
209
const startIndexes = regions . getStartIndexes ( ) ;
214
210
const endIndexes = regions . getEndIndexes ( ) ;
215
- console . log ( 'startIndexes : ' , startIndexes ) ;
216
- console . log ( 'endIndexes : ' , endIndexes ) ;
217
- let range = undefined ;
218
- const children = [ ] ;
219
- const stack = [ ] ;
220
- for ( let i = 1 ; i < startIndexes . length ; i ++ ) {
221
- range = new StickyRange ( startIndexes [ i ] , endIndexes [ i ] ) ;
211
+ if ( startIndexes . length === 0 ) {
212
+ return new StickyOutlineElement (
213
+ new StickyRange ( - 1 , - 1 ) ,
214
+ [ ] ,
215
+ undefined
216
+ ) ;
222
217
}
218
+ let range = undefined ;
219
+ const stackOfParents : StickyRange [ ] = [ ] ;
223
220
224
- //
225
- return new StickyOutlineElement (
226
- new StickyRange ( - 1 , - 1 ) ,
221
+ const stickyOutlineElement = new StickyOutlineElement (
222
+ undefined ,
227
223
[ ] ,
228
224
undefined
229
225
) ;
226
+ let parentStickyOutlineElement = stickyOutlineElement ;
227
+
228
+ for ( let i = 0 ; i < startIndexes . length ; i ++ ) {
229
+ range = new StickyRange ( startIndexes [ i ] , endIndexes [ i ] ) ;
230
+ while ( stackOfParents . length !== 0 && ( range . startLineNumber < ( stackOfParents [ stackOfParents . length - 1 ] as StickyRange ) . startLineNumber || range . endLineNumber > ( stackOfParents [ stackOfParents . length - 1 ] as StickyRange ) . endLineNumber ) ) {
231
+ stackOfParents . pop ( ) ;
232
+ if ( parentStickyOutlineElement . parent !== undefined ) {
233
+ parentStickyOutlineElement = parentStickyOutlineElement . parent ;
234
+ }
235
+ }
236
+ const child = new StickyOutlineElement (
237
+ range ,
238
+ [ ] ,
239
+ parentStickyOutlineElement
240
+ ) ;
241
+ parentStickyOutlineElement . children . push ( child ) ;
242
+ parentStickyOutlineElement = child ;
243
+ stackOfParents . push ( range ) ;
244
+ }
245
+ return stickyOutlineElement ;
230
246
}
231
247
232
248
constructor (
@@ -237,7 +253,7 @@ class StickyOutlineElement {
237
253
/**
238
254
* Must be sorted by start line number
239
255
*/
240
- public readonly children : readonly StickyOutlineElement [ ] ,
256
+ public children : StickyOutlineElement [ ] ,
241
257
/**
242
258
* Parent sticky outline element
243
259
*/
0 commit comments