@@ -92,7 +92,7 @@ export class StickyLineCandidateProvider extends Disposable {
92
92
if ( token . isCancellationRequested ) {
93
93
return ;
94
94
}
95
- this . _outlineModel = StickyOutlineElement . fromOutlineModel ( outlineModel ) ;
95
+ this . _outlineModel = StickyOutlineElement . fromOutlineModel ( outlineModel , - 1 ) ;
96
96
this . _modelVersionId = modelVersionId ;
97
97
}
98
98
}
@@ -158,12 +158,20 @@ export class StickyLineCandidateProvider extends Disposable {
158
158
}
159
159
160
160
class StickyOutlineElement {
161
- public static fromOutlineModel ( outlineModel : OutlineModel | OutlineElement | OutlineGroup ) : StickyOutlineElement {
161
+ public static fromOutlineModel ( outlineModel : OutlineModel | OutlineElement | OutlineGroup , previousStartLine : number ) : StickyOutlineElement {
162
162
163
163
const children : StickyOutlineElement [ ] = [ ] ;
164
164
for ( const child of outlineModel . children . values ( ) ) {
165
- if ( child instanceof OutlineElement && child . symbol . selectionRange . startLineNumber !== child . symbol . range . endLineNumber || child instanceof OutlineGroup || child instanceof OutlineModel ) {
166
- children . push ( StickyOutlineElement . fromOutlineModel ( child ) ) ;
165
+ if ( child instanceof OutlineGroup || child instanceof OutlineModel ) {
166
+ children . push ( StickyOutlineElement . fromOutlineModel ( child , - 1 ) ) ;
167
+ } else if ( child instanceof OutlineElement && child . symbol . selectionRange . startLineNumber !== child . symbol . range . endLineNumber ) {
168
+ if ( child . symbol . selectionRange . startLineNumber !== previousStartLine ) {
169
+ children . push ( StickyOutlineElement . fromOutlineModel ( child , child . symbol . selectionRange . startLineNumber ) ) ;
170
+ } else {
171
+ for ( const subchild of child . children . values ( ) ) {
172
+ children . push ( StickyOutlineElement . fromOutlineModel ( subchild , child . symbol . selectionRange . startLineNumber ) ) ;
173
+ }
174
+ }
167
175
}
168
176
}
169
177
children . sort ( ( child1 , child2 ) => {
0 commit comments