Skip to content

Commit 300a7f5

Browse files
author
aiday-mar
committed
1 parent ea6cfdd commit 300a7f5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/vs/editor/contrib/stickyScroll/browser/stickyScrollProvider.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class StickyLineCandidateProvider extends Disposable {
9292
if (token.isCancellationRequested) {
9393
return;
9494
}
95-
this._outlineModel = StickyOutlineElement.fromOutlineModel(outlineModel);
95+
this._outlineModel = StickyOutlineElement.fromOutlineModel(outlineModel, -1);
9696
this._modelVersionId = modelVersionId;
9797
}
9898
}
@@ -158,12 +158,20 @@ export class StickyLineCandidateProvider extends Disposable {
158158
}
159159

160160
class StickyOutlineElement {
161-
public static fromOutlineModel(outlineModel: OutlineModel | OutlineElement | OutlineGroup): StickyOutlineElement {
161+
public static fromOutlineModel(outlineModel: OutlineModel | OutlineElement | OutlineGroup, previousStartLine: number): StickyOutlineElement {
162162

163163
const children: StickyOutlineElement[] = [];
164164
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+
}
167175
}
168176
}
169177
children.sort((child1, child2) => {

0 commit comments

Comments
 (0)