Fix sluggish mouse problem. Now similar to trackpad

This commit is contained in:
Anthony Kim
2025-09-08 21:03:05 -07:00
parent b104a5b953
commit 26ecba8de1
4 changed files with 7 additions and 6 deletions
+2 -2
View File
@@ -646,7 +646,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
if (deltaY === 0) {
return false;
}
const lines = self.coreMouseService.consumeWhellEvent(
const lines = self.coreMouseService.consumeWheelEvent(
ev as WheelEvent,
self._renderService?.dimensions?.device?.cell?.height,
self._coreBrowserService?.dpr
@@ -825,7 +825,7 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
return false;
}
const lines = self.coreMouseService.consumeWhellEvent(
const lines = self.coreMouseService.consumeWheelEvent(
ev as WheelEvent,
self._renderService?.dimensions?.device?.cell?.height,
self._coreBrowserService?.dpr
+1 -1
View File
@@ -66,7 +66,7 @@ export class MockCoreMouseService implements ICoreMouseService {
public explainEvents(events: CoreMouseEventType): { [event: string]: boolean } {
throw new Error('Method not implemented.');
}
public consumeWhellEvent(ev: WheelEvent, cellHeight: number, dpr: number): number {
public consumeWheelEvent(ev: WheelEvent, cellHeight: number, dpr: number): number {
return 1; // Return a simple mock value
}
}
+3 -2
View File
@@ -237,7 +237,7 @@ export class CoreMouseService extends Disposable implements ICoreMouseService {
* Processes a wheel event, accounting for partial scrolls for trackpad, mouse scrolls.
* This prevents hyper-sensitive scrolling in alt buffer.
*/
public consumeWhellEvent(ev: WheelEvent, cellHeight?: number, dpr?: number): number {
public consumeWheelEvent(ev: WheelEvent, cellHeight?: number, dpr?: number): number {
// Do nothing if it's not a vertical scroll event
if (ev.deltaY === 0 || ev.shiftKey) {
return 0;
@@ -251,7 +251,8 @@ export class CoreMouseService extends Disposable implements ICoreMouseService {
const targetWheelEventPixels = cellHeight / dpr;
let amount = 1;
if (ev.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
amount /= targetWheelEventPixels + 0.0; // Prevent integer division
const pixelAmount = ev.deltaY;
amount = pixelAmount / (targetWheelEventPixels + 0.0); // Prevent integer division
this._wheelPartialScroll += amount;
amount = Math.floor(Math.abs(this._wheelPartialScroll)) * (this._wheelPartialScroll > 0 ? 1 : -1);
this._wheelPartialScroll %= 1;
+1 -1
View File
@@ -62,7 +62,7 @@ export interface ICoreMouseService {
/**
* Process wheel event taking partial scroll into account.
*/
consumeWhellEvent(ev: WheelEvent, cellHeight?: number, dpr?: number): number;
consumeWheelEvent(ev: WheelEvent, cellHeight?: number, dpr?: number): number;
}
export const ICoreService = createDecorator<ICoreService>('CoreService');