@@ -99,7 +99,10 @@ export class StickyLineCandidateProvider extends Disposable {
99
99
} else {
100
100
const foldingController = FoldingController . get ( this . _editor ) ;
101
101
const foldingModel = await foldingController ?. getFoldingModel ( ) ;
102
- if ( foldingModel ) {
102
+ if ( token . isCancellationRequested ) {
103
+ return ;
104
+ }
105
+ if ( foldingModel && foldingModel . regions . length !== 0 ) {
103
106
this . _outlineModel = StickyOutlineElement . fromFoldingModel ( foldingModel ) ;
104
107
} else {
105
108
this . _outlineModel = new StickyOutlineElement (
@@ -205,17 +208,9 @@ class StickyOutlineElement {
205
208
}
206
209
207
210
public static fromFoldingModel ( foldingModel : FoldingModel ) : StickyOutlineElement {
208
- const regions = foldingModel . getRegions ( ) ;
209
- const startIndexes = regions . getStartIndexes ( ) ;
210
- const endIndexes = regions . getEndIndexes ( ) ;
211
- if ( startIndexes . length === 0 ) {
212
- return new StickyOutlineElement (
213
- new StickyRange ( - 1 , - 1 ) ,
214
- [ ] ,
215
- undefined
216
- ) ;
217
- }
218
- let range = undefined ;
211
+ const regions = foldingModel . regions ;
212
+ const length = regions . length ;
213
+ let range : StickyRange | undefined ;
219
214
const stackOfParents : StickyRange [ ] = [ ] ;
220
215
221
216
const stickyOutlineElement = new StickyOutlineElement (
@@ -225,9 +220,9 @@ class StickyOutlineElement {
225
220
) ;
226
221
let parentStickyOutlineElement = stickyOutlineElement ;
227
222
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 ) ) {
223
+ for ( let i = 0 ; i < length ; i ++ ) {
224
+ range = new StickyRange ( regions . getStartLineNumber ( i ) , regions . getEndLineNumber ( i ) ) ;
225
+ while ( stackOfParents . length !== 0 && ( range . startLineNumber < stackOfParents [ stackOfParents . length - 1 ] . startLineNumber || range . endLineNumber > stackOfParents [ stackOfParents . length - 1 ] . endLineNumber ) ) {
231
226
stackOfParents . pop ( ) ;
232
227
if ( parentStickyOutlineElement . parent !== undefined ) {
233
228
parentStickyOutlineElement = parentStickyOutlineElement . parent ;
@@ -253,7 +248,7 @@ class StickyOutlineElement {
253
248
/**
254
249
* Must be sorted by start line number
255
250
*/
256
- public children : StickyOutlineElement [ ] ,
251
+ public readonly children : StickyOutlineElement [ ] ,
257
252
/**
258
253
* Parent sticky outline element
259
254
*/
0 commit comments