Skip to content

Commit

Permalink
Not sticking outlines which span only one line
Browse files Browse the repository at this point in the history
  • Loading branch information
aiday-mar committed Jul 26, 2022
1 parent f37293c commit 9f331b7
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,29 +183,31 @@ class StickyScrollController implements IEditorContribution {

for (const [index, arr] of this._ranges.entries()) {
const [start, end, depth] = arr;
topOfElementAtDepth = this._editor.getScrollTop() + (depth - 1) * lineHeight;
bottomOfElementAtDepth = this._editor.getScrollTop() + depth * lineHeight;
bottomOfBeginningLine = start * lineHeight;
topOfEndLine = (end - 1) * lineHeight;
bottomOfEndLine = end * lineHeight;

if (!beginningLinesConsidered.has(start)) {
if (topOfElementAtDepth >= topOfEndLine - 1 && topOfElementAtDepth < bottomOfEndLine - 2) {
beginningLinesConsidered.add(start);
this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, -1, (depth - 1) * lineHeight + bottomOfEndLine - bottomOfElementAtDepth));
break;
}
else if (scrollDirection === ScrollDirection.Down && bottomOfElementAtDepth > bottomOfBeginningLine - 1 && bottomOfElementAtDepth < bottomOfEndLine - 1) {
beginningLinesConsidered.add(start);
this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, 0));

} else if (scrollDirection === ScrollDirection.Up && scrollToBottomOfWidget > bottomOfBeginningLine - 1 && scrollToBottomOfWidget < bottomOfEndLine ||
scrollDirection === ScrollDirection.Up && bottomOfElementAtDepth > bottomOfBeginningLine && bottomOfElementAtDepth < topOfEndLine - 1) {
beginningLinesConsidered.add(start);
this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, 0));
if (end - start > 0) {
topOfElementAtDepth = this._editor.getScrollTop() + (depth - 1) * lineHeight;
bottomOfElementAtDepth = this._editor.getScrollTop() + depth * lineHeight;
bottomOfBeginningLine = start * lineHeight;
topOfEndLine = (end - 1) * lineHeight;
bottomOfEndLine = end * lineHeight;

if (!beginningLinesConsidered.has(start)) {
if (topOfElementAtDepth >= topOfEndLine - 1 && topOfElementAtDepth < bottomOfEndLine - 2) {
beginningLinesConsidered.add(start);
this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, -1, (depth - 1) * lineHeight + bottomOfEndLine - bottomOfElementAtDepth));
break;
}
else if (scrollDirection === ScrollDirection.Down && bottomOfElementAtDepth > bottomOfBeginningLine - 1 && bottomOfElementAtDepth < bottomOfEndLine - 1) {
beginningLinesConsidered.add(start);
this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, 0));

} else if (scrollDirection === ScrollDirection.Up && scrollToBottomOfWidget > bottomOfBeginningLine - 1 && scrollToBottomOfWidget < bottomOfEndLine ||
scrollDirection === ScrollDirection.Up && bottomOfElementAtDepth > bottomOfBeginningLine && bottomOfElementAtDepth < topOfEndLine - 1) {
beginningLinesConsidered.add(start);
this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(model.getLineContent(start), start, this._editor, 0));
}
} else {
this._ranges.splice(index, 1);
}
} else {
this._ranges.splice(index, 1);
}
}

Expand Down

0 comments on commit 9f331b7

Please sign in to comment.