Skip to content

Commit

Permalink
Fixes #216824
Browse files Browse the repository at this point in the history
  • Loading branch information
hediet committed Jul 8, 2024
1 parent 58c354a commit 6a70bcf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/vs/editor/browser/stableEditorScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ export class StableEditorScrollState {
const visibleRanges = editor.getVisibleRanges();
if (visibleRanges.length > 0) {
visiblePosition = visibleRanges[0].getStartPosition();

const cursorPos = editor.getPosition();
if (cursorPos) {
const isVisible = visibleRanges.some(range => range.containsPosition(cursorPos));
if (isVisible) {
// Keep cursor pos fixed if it is visible
visiblePosition = cursorPos;
}
}

const visiblePositionScrollTop = editor.getTopForPosition(visiblePosition.lineNumber, visiblePosition.column);
visiblePositionScrollDelta = editor.getScrollTop() - visiblePositionScrollTop;
}
Expand Down

0 comments on commit 6a70bcf

Please sign in to comment.