Skip to content

Commit 458d44c

Browse files
author
aiday-mar
committed
Fix: incorrect calculation of the depth
1 parent 62f7d89 commit 458d44c

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

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

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -126,30 +126,34 @@ class StickyScrollController implements IEditorContribution {
126126
this._ranges = [];
127127
for (const outline of outlineModel.children.values()) {
128128
if (outline instanceof OutlineElement) {
129-
this._findLineRanges(outline, 1);
129+
const kind: SymbolKind = outline.symbol.kind;
130+
if (kind === SymbolKind.Class || kind === SymbolKind.Constructor || kind === SymbolKind.Function || kind === SymbolKind.Interface || kind === SymbolKind.Method) {
131+
this._findLineRanges(outline, 1);
132+
} else {
133+
this._findLineRanges(outline, 0);
134+
}
130135
}
131-
}
132-
this._ranges = this._ranges.sort(function (a, b) {
133-
if (a[0] !== b[0]) {
134-
return a[0] - b[0];
135-
} else if (a[1] !== b[1]) {
136-
return b[1] - a[1];
137-
} else {
138-
return a[2] - b[2];
139-
}
140-
});
141-
let previous: number[] = [];
142-
for (const [index, arr] of this._ranges.entries()) {
143-
const [start, end, _depth] = arr;
144-
if (previous[0] === start && previous[1] === end) {
145-
this._ranges.splice(index, 1);
146-
} else {
147-
previous = arr;
136+
this._ranges = this._ranges.sort(function (a, b) {
137+
if (a[0] !== b[0]) {
138+
return a[0] - b[0];
139+
} else if (a[1] !== b[1]) {
140+
return b[1] - a[1];
141+
} else {
142+
return a[2] - b[2];
143+
}
144+
});
145+
let previous: number[] = [];
146+
for (const [index, arr] of this._ranges.entries()) {
147+
const [start, end, _depth] = arr;
148+
if (previous[0] === start && previous[1] === end) {
149+
this._ranges.splice(index, 1);
150+
} else {
151+
previous = arr;
152+
}
148153
}
149154
}
150155
}
151156
}
152-
153157
private _renderStickyScroll() {
154158

155159
if (!(this._editor.hasModel())) {

0 commit comments

Comments
 (0)