Change:
export class StableEditorScrollState { public static capture(editor: ICodeEditor): StableEditorScrollState { <ins> if (editor.getScrollTop() === 0 || editor.hasPendingScrollAnimation()) { // Never mess with the scroll top if the editor is at the top of the file or if there is a pending scroll animation return new StableEditorScrollState(editor.getScrollTop(), editor.getContentHeight(), null, 0, null); } </ins> let visiblePosition: Position | null = null; let visiblePositionScrollDelta = 0; <del> if (editor.getScrollTop() !== 0) { const visibleRanges = editor.getVisibleRanges(); if (visibleRanges.length > 0) { visiblePosition = visibleRanges[0].getStartPosition(); const visiblePositionScrollTop = editor.getTopForPosition(visiblePosition.lineNumber, visiblePosition.column); visiblePositionScrollDelta = editor.getScrollTop() - visiblePositionScrollTop; } </del> <ins> const visibleRanges = editor.getVisibleRanges(); if (visibleRanges.length > 0) { visiblePosition = visibleRanges[0].getStartPosition(); const visiblePositionScrollTop = editor.getTopForPosition(visiblePosition.lineNumber, visiblePosition.column); visiblePositionScrollDelta = editor.getScrollTop() - visiblePositionScrollTop; </ins> } <del> return new StableEditorScrollState(visiblePosition, visiblePositionScrollDelta, editor.getPosition()); </del> <ins> return new StableEditorScrollState(editor.getScrollTop(), editor.getContentHeight(), visiblePosition, visiblePositionScrollDelta, editor.getPosition()); </ins> } constructor( <ins> private readonly _initialScrollTop: number, private readonly _initialContentHeight: number, </ins> private readonly _visiblePosition: Position | null, private readonly _visiblePositionScrollDelta: number, <del> private readonly _cursorPosition: Position | null </del> <ins> private readonly _cursorPosition: Position | null, </ins> ) { } public restore(editor: ICodeEditor): void { <ins> if (this._initialContentHeight === editor.getContentHeight() && this._initialScrollTop === editor.getScrollTop()) { // The editor's content height and scroll top haven't changed, so we don't need to do anything return; } </ins> if (this._visiblePosition) { const visiblePositionScrollTop = editor.getTopForPosition(this._visiblePosition.lineNumber, this._visiblePosition.column); editor.setScrollTop(visiblePositionScrollTop + this._visiblePositionScrollDelta);

Discussion:
Type: <bBug</bI found this problem in Vim extension when using half page scroll with centered view and smoothScrolling, and reproduce this bug in test clean extension. Without smoothScrolling it works fine. When executing command two times with ~150ms delay second action dont trigger (view stay in position by first ). U can see it on this video, when view in some cases not returned to 31 line from 39. https://user- Reproduce: reproducing i set interval with two timeouts to create delay between two executions and set smoothScrolling. ! VS Code version: Code 1.76.2 (, 2023-03-14T17:55:54.936Z) OS version: WindowsNT x64 10.0.

Modes: Unsupported Sandboxed: No <details<summarySystem Info</summary </details<details<summaryExtensions (35)</summaryExtensionVersion ------ better-comments3.0.2 astro-vscode0.28.2 vscode-tailwindcss0.9.11 path-intellisense2.8.4 vscode-css-modules0.4.2 vscode-database-client26.3.4 vscode-eslint2.4.0 es7-react-js-snippets4.4.3 vsc-material-theme-icons2.7.4 prettier-vscode9.10.4 auto-close-tag0.5.14 auto-rename-tag0.1.10 code-runner0.12.0 geril-vim1.25.2 go0.38.0 vscode-graphql0.8.7 vscode-graphql-syntax1.1.0 code-background2.5.4 vscode-docker1.24.0 remote-wsl0.76.1 remote-explorer0.4.0 remote-server1.0.0 material-icon-theme4.25.0 prisma4.12.0 LiveServer5.7.9 rust-analyzer0.3.1463 vscode-styled-components1.7.8 svelte-vscode107.3.0 errorlens3.8.0 intellicode-api-usage-examples0.2.7 vscodeintellicode1.2.30 vscode-icons12.2.0 JavaScriptSnippets1.8.0 material-theme3.15.8 vscode-proto30.5.5 (2 theme extensions excluded) </details<details<summaryA/B Experiments</summary</details<!-- generated by issue reporter --
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.77.1. Please try upgrading to the latest version and checking whether this issue remains. Happy Coding!
After update to 1.77.1 bug still exists
Thank you for the repro! The root cause is this particular call - introduced via cc That code runs even when the inlayHintsController doesn't do anything and it ends up interrupting the current editor scroll animation.