-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
Milestone
Description
Original issue: microsoft/vscode#63669
Using these mouse settings on Windows 10:
The terminal seems to scroll 7 lines instead of 3.
Code pointer:
Lines 160 to 190 in 290c95a
| /** | |
| * Handles mouse wheel events by adjusting the viewport's scrollTop and delegating the actual | |
| * scrolling to `onScroll`, this event needs to be attached manually by the consumer of | |
| * `Viewport`. | |
| * @param ev The mouse wheel event. | |
| */ | |
| public onWheel(ev: WheelEvent): void { | |
| const amount = this._getPixelsScrolled(ev); | |
| if (amount === 0) { | |
| return; | |
| } | |
| this._viewportElement.scrollTop += amount; | |
| // Prevent the page from scrolling when the terminal scrolls | |
| ev.preventDefault(); | |
| } | |
| private _getPixelsScrolled(ev: WheelEvent): number { | |
| // Do nothing if it's not a vertical scroll event | |
| if (ev.deltaY === 0) { | |
| return 0; | |
| } | |
| // Fallback to WheelEvent.DOM_DELTA_PIXEL | |
| let amount = ev.deltaY; | |
| if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) { | |
| amount *= this._currentRowHeight; | |
| } else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) { | |
| amount *= this._currentRowHeight * this._terminal.rows; | |
| } | |
| return amount; | |
| } |
