fix: avoid jumpy scrolling when navigating next/prev problem#285634
fix: avoid jumpy scrolling when navigating next/prev problem#285634jrieken merged 1 commit intomicrosoft:mainfrom
Conversation
When navigating to the next/prev problem using editor.action.marker.next, the editor would always scroll the marker to the top of the viewport (using revealPositionNearTop), even if the marker was already visible or just slightly off-screen. This caused a "jumpy" experience and confusion. Changed to use revealPositionInCenterIfOutsideViewport, which maintains context by only scrolling if necessary, and centers the marker if it is significantly far away. Fixes microsoft#156782
There was a problem hiding this comment.
Pull request overview
This PR fixes jumpy scrolling behavior when navigating between problems using F8 (next marker) and Shift+Alt+F8 (previous marker). The change replaces aggressive top-of-viewport scrolling with context-aware scrolling that only scrolls when necessary and centers the marker in the viewport.
Key Changes:
- Changed scrolling behavior from
revealPositionNearToptorevealPositionInCenterIfOutsideViewportfor smoother navigation - Scrolling now only occurs if the marker is outside the viewport, preserving context when the marker is already visible
| this._icon.className = `codicon ${SeverityIcon.className(MarkerSeverity.toSeverity(this._severity))}`; | ||
|
|
||
| this.editor.revealPositionNearTop(position, ScrollType.Smooth); | ||
| this.editor.revealPositionInCenterIfOutsideViewport(position, ScrollType.Smooth); |
There was a problem hiding this comment.
While this change improves the scrolling behavior for same-file marker navigation, there's an inconsistency when navigating to markers in different files. In gotoError.ts line 160, the code uses TextEditorSelectionRevealType.NearTop when opening a marker in a different editor. For consistency, this should also use TextEditorSelectionRevealType.CenterIfOutsideViewport to provide the same smooth navigation experience across files.
Summary
When navigating to the next/prev problem using
editor.action.marker.next(F8), the editor would always scroll the marker to the top of the viewport usingrevealPositionNearTop. This caused abrupt jumps even when the next error was just slightly below the fold or already visible, leading to loss of context.Change
Replaced
revealPositionNearTopwithrevealPositionInCenterIfOutsideViewport. This ensures that:ScrollType.Smooth).Modified File
src/vs/editor/contrib/gotoError/browser/gotoErrorWidget.tsFixes #156782