@@ -97,49 +97,28 @@ export class StickyLineCandidateProvider extends Disposable {
97
97
}
98
98
}
99
99
100
- private changeIndex ( index : number ) {
100
+ private updatedIndex ( index : number ) {
101
101
if ( index === - 1 ) {
102
102
index = 0 ;
103
103
} else if ( index < 0 ) {
104
104
index = - index - 2 ;
105
105
}
106
106
return index ;
107
107
}
108
+
108
109
public getCandidateStickyLinesIntersectingFromOutline ( range : StickyRange , outlineModel : StickyOutlineElement , result : StickyLineCandidate [ ] , depth : number , lastStartLineNumber : number ) : void {
110
+ if ( outlineModel . children . length === 0 ) {
111
+ return ;
112
+ }
109
113
let lastLine = lastStartLineNumber ;
110
- // Find largest number in the start lines being smaller than the current range start line
111
114
const childrenStartLines = outlineModel . children . map ( child => child . range ?. startLineNumber as number ) ;
112
115
let indexLower = binarySearch ( childrenStartLines , range . startLineNumber , ( a : number , b : number ) => { return a - b ; } ) ;
113
116
let indexUpper = binarySearch ( childrenStartLines , range . startLineNumber + depth , ( a : number , b : number ) => { return a - b ; } ) ;
114
- console . log ( 'children start lines : ' , childrenStartLines ) ;
115
- console . log ( 'range start line number : ' , range . startLineNumber ) ;
116
- console . log ( 'range.startLineNumber + depth : ' , range . startLineNumber + depth ) ;
117
- console . log ( 'index lower before change : ' , indexLower ) ;
118
- console . log ( 'index upper before change : ' , indexUpper ) ;
119
-
120
- indexLower = this . changeIndex ( indexLower ) ;
121
- indexUpper = this . changeIndex ( indexUpper ) ;
122
-
123
- console . log ( 'indexLower : ' , indexLower ) ;
124
- console . log ( 'indexUpper : ' , indexUpper ) ;
117
+ indexLower = this . updatedIndex ( indexLower ) ;
118
+ indexUpper = this . updatedIndex ( indexUpper ) ;
125
119
126
120
for ( let i = indexLower ; i <= indexUpper ; i ++ ) {
127
- console . log ( 'currently at index : ' , i ) ;
128
121
const child = outlineModel . children [ i ] ;
129
- if ( child && child . range ) {
130
- const childStartLine = child . range . startLineNumber ;
131
- const childEndLine = child . range . endLineNumber ;
132
- if ( range . startLineNumber <= childEndLine + 1 && childStartLine - 1 <= range . endLineNumber && childStartLine !== lastLine ) {
133
- lastLine = childStartLine ;
134
- result . push ( new StickyLineCandidate ( childStartLine , childEndLine - 1 , depth + 1 ) ) ;
135
- this . getCandidateStickyLinesIntersectingFromOutline ( range , child , result , depth + 1 , childStartLine ) ;
136
- }
137
- } else {
138
- this . getCandidateStickyLinesIntersectingFromOutline ( range , child , result , depth , lastStartLineNumber ) ;
139
- }
140
- }
141
- /*
142
- for (const child of outlineModel.children) {
143
122
if ( child . range ) {
144
123
const childStartLine = child . range . startLineNumber ;
145
124
const childEndLine = child . range . endLineNumber ;
@@ -152,15 +131,11 @@ export class StickyLineCandidateProvider extends Disposable {
152
131
this . getCandidateStickyLinesIntersectingFromOutline ( range , child , result , depth , lastStartLineNumber ) ;
153
132
}
154
133
}
155
- */
156
134
}
157
135
158
136
public getCandidateStickyLinesIntersecting ( range : StickyRange ) : StickyLineCandidate [ ] {
159
137
let stickyLineCandidates : StickyLineCandidate [ ] = [ ] ;
160
- console . log ( 'this._outlineModel : ' , this . _outlineModel ) ;
161
- console . log ( 'range : ' , range ) ;
162
138
this . getCandidateStickyLinesIntersectingFromOutline ( range , this . _outlineModel as StickyOutlineElement , stickyLineCandidates , 0 , - 1 ) ;
163
- console . log ( 'stickyLineCandidates : ' , stickyLineCandidates ) ;
164
139
const hiddenRanges : Range [ ] | undefined = this . _editor . _getViewModel ( ) ?. getHiddenAreas ( ) ;
165
140
if ( hiddenRanges ) {
166
141
for ( const hiddenRange of hiddenRanges ) {
0 commit comments