Skip to content

Commit 5d16a27

Browse files
author
aiday-mar
committed
Rendering the sticky line when one pixel into the line. Fixes microsoft#156566.
1 parent 589aba9 commit 5d16a27

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ class StickyScrollController extends Disposable implements IEditorContribution {
210210
if (!beginningLinesConsidered.has(start)) {
211211
if (topOfElementAtDepth >= topOfEndLine - 1 && topOfElementAtDepth < bottomOfEndLine - 2) {
212212
beginningLinesConsidered.add(start);
213-
this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(start, this._editor, -1, bottomOfEndLine - bottomOfElementAtDepth));
213+
this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(start, depth, this._editor, -1, bottomOfEndLine - bottomOfElementAtDepth));
214214
break;
215215
}
216-
else if (bottomOfElementAtDepth > bottomOfBeginningLine - 1 && bottomOfElementAtDepth < bottomOfEndLine - 1) {
216+
else if (bottomOfElementAtDepth > bottomOfBeginningLine && bottomOfElementAtDepth < bottomOfEndLine - 1) {
217217
beginningLinesConsidered.add(start);
218-
this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(start, this._editor, 0, 0));
218+
this.stickyScrollWidget.pushCodeLine(new StickyScrollCodeLine(start, depth, this._editor, 0, 0));
219219
}
220220
} else {
221221
this._ranges.splice(index, 1);
@@ -237,7 +237,7 @@ class StickyScrollCodeLine {
237237

238238
public readonly effectiveLineHeight: number = 0;
239239

240-
constructor(private readonly _lineNumber: number, private readonly _editor: IActiveCodeEditor,
240+
constructor(private readonly _lineNumber: number, private readonly _depth: number, private readonly _editor: IActiveCodeEditor,
241241
private readonly _zIndex: number, private readonly _relativePosition: number) {
242242
this.effectiveLineHeight = this._editor.getOption(EditorOption.lineHeight) + this._relativePosition;
243243
}
@@ -302,8 +302,9 @@ class StickyScrollCodeLine {
302302
root.onclick = e => {
303303
e.stopPropagation();
304304
e.preventDefault();
305-
this._editor.revealLine(this._lineNumber);
305+
this._editor.revealPosition({ lineNumber: this._lineNumber - this._depth + 1, column: 1 });
306306
};
307+
307308
root.onmouseover = e => {
308309
innerLineNumberHTML.style.background = `var(--vscode-editorStickyScrollHover-background)`;
309310
lineHTMLNode.style.backgroundColor = `var(--vscode-editorStickyScrollHover-background)`;
@@ -353,7 +354,7 @@ class StickyScrollWidget implements IOverlayWidget {
353354
constructor(public readonly _editor: ICodeEditor) {
354355
this.rootDomNode = document.createElement('div');
355356
this.rootDomNode.style.width = '100%';
356-
this.rootDomNode.style.boxShadow = `var(--vscode-scrollbar-shadow) 0 6px 6px -6px`; // '0px 0px 8px 2px #000000';
357+
this.rootDomNode.style.boxShadow = `var(--vscode-scrollbar-shadow) 0 6px 6px -6px`;
357358
}
358359

359360
get codeLineCount() {

0 commit comments

Comments
 (0)