Change:
Issue Type: <bBug</bI have been using for a long time. Currently I end up with a LOT of inadvertant selections when working in two side-by-side editor groups and switching back and forth between them using the mouse. The reason is that the editor scrolls 5 lines every time I click into it. VS Code version: Code - Insiders 1.58.0-insider (, 2021-06-11T05:22:19.992Z) OS version: Darwin arm64 20.5.0 Restricted Mode: No Remote OS version: Linux x64 5.4.0-1046-azure <!-- generated by issue reporter --
I cannot reproduce. Does this reproduce for you when disabling all extensions? (The editor exposes a API to extensions). I have recently also got which seems incredibly similar, but I am having a hard time reproducing any of the jumping that is described. Here I am trying two side-by-side editor groups: https://user-
This reproduces only when the language mode of the files are set to markdown. I think this has to do with how the markdown extension is using the vscode API. But I think it should not use that API at all if no markdown preview is rendered. But it would also be interesting to test what the experience is when the preview is rendered. Given this doesn't reproduce with txt files, I'm optimistically giving this to you. Steps to reproduce: define open two md files side-by-side (preferably without word wrapping to see the top line number change) click on the editor tab of each one on every click, the editor scrolls up by 5 lines https://user-
Could you please take a look at this since you were looking into markdown syncing last iteration?
It seems like it's a bug coming from the scroll syncing between the static and text editor changes that I made a while ago. I'll try to make a PR to fix this soon.

Discussion:
})); this._register(this.preview.onScroll((scrollInfo) => { <del> topmostLineMonitor.setPreviousEditorLine(scrollInfo); </del> <ins> topmostLineMonitor.setPreviousStaticEditorLine(scrollInfo); </ins> })); this._register(topmostLineMonitor.onDidChanged(event => {

// When at a markdown file, apply existing scroll settings if (textEditor && textEditor.document && isMarkdownFile(textEditor.document)) { <del> const line = this._topmostLineMonitor.getPreviousEditorLineByUri(textEditor.document.uri); </del> <ins> const line = this._topmostLineMonitor.getPreviousStaticEditorLineByUri(textEditor.document.uri); </ins> if (line) { scrollEditorToLine(line, textEditor); }

document: vscode.TextDocument, webview: vscode.WebviewPanel ): Promise<void> { <del> const lineNumber = this._topmostLineMonitor.getPreviousEditorLineByUri(document.uri); </del> <ins> const lineNumber = this._topmostLineMonitor.getPreviousTextEditorLineByUri(document.uri); </ins> const preview = StaticMarkdownPreview.revive( document.uri, webview,

private readonly pendingUpdates = new Map<string, number>(); private readonly throttle = 50; <del> private previousEditorInfo = new Map<string, LastScrollLocation>(); public isPrevEditorCustom = false; </del> <ins> private previousTextEditorInfo = new Map<string, LastScrollLocation>(); private previousStaticEditorInfo = new Map<string, LastScrollLocation>(); </ins> constructor() { super(); if (vscode.window.activeTextEditor) { const line = getVisibleLine(vscode.window.activeTextEditor); <del> this.setPreviousEditorLine({ uri: vscode.window.activeTextEditor.document.uri, line: line ?? 0 }); </del> <ins> this.setPreviousTextEditorLine({ uri: vscode.window.activeTextEditor.document.uri, line: line ?? 0 }); </ins> } this._register(vscode.window.onDidChangeTextEditorVisibleRanges(event => {

const line = getVisibleLine(event.textEditor); if (typeof line === 'number') { this.updateLine(event.textEditor.document.uri, line); <del> this.setPreviousEditorLine({ uri: event.textEditor.document.uri, line: line }); </del> <ins> this.setPreviousTextEditorLine({ uri: event.textEditor.document.uri, line: line }); </ins> } } }));

private readonly _onChanged = this._register(new vscode.EventEmitter<{ readonly resource: vscode.Uri, readonly line: number }>()); public readonly onDidChanged = this._onChanged.event; <del> public setPreviousEditorLine(scrollLocation: LastScrollLocation): void { this.previousEditorInfo.set(scrollLocation.uri.toString(), scrollLocation); </del> <ins> public setPreviousStaticEditorLine(scrollLocation: LastScrollLocation): void { this.previousStaticEditorInfo.set(scrollLocation.uri.toString(), scrollLocation); </ins> } <del> public getPreviousEditorLineByUri(resource: vscode.Uri): number | undefined { const scrollLoc = this.previousEditorInfo.get(resource.toString()); </del> <ins> public getPreviousStaticEditorLineByUri(resource: vscode.Uri): number | undefined { const scrollLoc = this.previousStaticEditorInfo.get(resource.toString()); this.previousStaticEditorInfo.delete(resource.toString()); return scrollLoc?.line; } public setPreviousTextEditorLine(scrollLocation: LastScrollLocation): void { this.previousTextEditorInfo.set(scrollLocation.uri.toString(), scrollLocation); } public getPreviousTextEditorLineByUri(resource: vscode.Uri): number | undefined { const scrollLoc = this.previousTextEditorInfo.get(resource.toString()); this.previousTextEditorInfo.delete(resource.toString()); </ins> return scrollLoc?.line; }