diff options
author | aiday-mar <t-aidaym@microsoft.com> | 2022-07-26 18:35:46 +0300 |
---|---|---|
committer | aiday-mar <t-aidaym@microsoft.com> | 2022-07-26 18:35:46 +0300 |
commit | 9f331b70b668621f90ba9517b6fe335d8f6b4ef0 (patch) | |
tree | 094bd4a39d7985e8fb6d41de87c3ecdc5a2328f4 /src/vs | |
parent | f37293c6c0e739bf0837a9ed7b3405c6d14add0d (diff) |
Not sticking outlines which span only one line
Diffstat (limited to 'src/vs')
-rw-r--r-- | src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts b/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts index ca723e08050..8e76db3d0a4 100644 --- a/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts +++ b/src/vs/editor/contrib/stickyScroll/browser/stickyScroll.ts @@ -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); } } |