Fix synchronization of scrolling event flooding (#209021)

fixes #209020
This commit is contained in:
Benjamin Christopher Simmonds 2024-03-28 15:39:47 +01:00 committed by GitHub
parent a1d4ad1847
commit 64c2cfccd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,6 +12,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { SideBySideEditor } from 'vs/workbench/browser/parts/editor/sideBySideEditor';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IEditorPane, IEditorPaneScrollPosition, isEditorPaneWithScrolling } from 'vs/workbench/common/editor';
import { ReentrancyBarrier } from 'vs/workbench/contrib/mergeEditor/browser/utils';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IStatusbarEntryAccessor, IStatusbarService, StatusbarAlignment } from 'vs/workbench/services/statusbar/browser/statusbar';
@ -59,6 +60,9 @@ export class SyncScroll extends Disposable implements IWorkbenchContribution {
this.toggleStatusbarItem(this.isActive);
}
// makes sure that the onDidEditorPaneScroll is not called multiple times for the same event
private _reentrancyBarrier = new ReentrancyBarrier();
private trackVisiblePanes(): void {
this.paneDisposables.clear();
this.paneInitialScrollTop.clear();
@ -70,7 +74,11 @@ export class SyncScroll extends Disposable implements IWorkbenchContribution {
}
this.paneInitialScrollTop.set(pane, pane.getScrollPosition());
this.paneDisposables.add(pane.onDidChangeScroll(() => this.onDidEditorPaneScroll(pane)));
this.paneDisposables.add(pane.onDidChangeScroll(() =>
this._reentrancyBarrier.runExclusively(() => {
this.onDidEditorPaneScroll(pane);
})
));
}
}