@@ -646,6 +646,10 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
646646 if ( deltaY === 0 ) {
647647 return false ;
648648 }
649+ const lines = self . _consumeWheelEvent ( ev as WheelEvent ) ;
650+ if ( lines === 0 ) {
651+ return false ;
652+ }
649653 action = deltaY < 0 ? CoreMouseAction . UP : CoreMouseAction . DOWN ;
650654 but = CoreMouseButton . WHEEL ;
651655 break ;
@@ -817,6 +821,11 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
817821 return false ;
818822 }
819823
824+ const lines = self . _consumeWheelEvent ( ev as WheelEvent ) ;
825+ if ( lines === 0 ) {
826+ return false ;
827+ }
828+
820829 // Construct and send sequences
821830 const sequence = C0 . ESC + ( this . coreService . decPrivateModes . applicationCursorKeys ? 'O' : '[' ) + ( ev . deltaY < 0 ? 'A' : 'B' ) ;
822831 this . coreService . triggerDataEvent ( sequence , true ) ;
@@ -825,6 +834,38 @@ export class CoreBrowserTerminal extends CoreTerminal implements ITerminal {
825834 } , { passive : false } ) ) ;
826835 }
827836
837+ // Stores a partial line amount when scrolling, this is used to keep track of how much of a line
838+ // is scrolled so we can "scroll" over partial lines and feel natural on touchpads. This is a
839+ // quick fix and could have a more robust solution in place that reset the value when needed.
840+ private _wheelPartialScroll : number = 0 ;
841+
842+ /**
843+ * Gets the number of pixels scrolled by the mouse event taking into account what type of delta
844+ * is being used.
845+ * @param ev The mouse wheel event.
846+ */
847+ private _consumeWheelEvent ( ev : WheelEvent ) : number {
848+ // Do nothing if it's not a vertical scroll event
849+ if ( ev . deltaY === 0 || ev . shiftKey ) {
850+ return 0 ;
851+ }
852+
853+ if ( ! this . _coreBrowserService || ! this . _renderService ) {
854+ return 0 ;
855+ }
856+ // Fallback to WheelEvent.DOM_DELTA_LINE
857+ const targetWheelEventPixels = this . _renderService . dimensions . device . cell . height / this . _coreBrowserService . dpr ;
858+ let amount = 1 ;
859+ if ( ev . deltaMode === WheelEvent . DOM_DELTA_PIXEL ) {
860+ amount /= targetWheelEventPixels + 0.0 ; // Prevent integer division
861+ this . _wheelPartialScroll += amount ;
862+ amount = Math . floor ( Math . abs ( this . _wheelPartialScroll ) ) * ( this . _wheelPartialScroll > 0 ? 1 : - 1 ) ;
863+ this . _wheelPartialScroll %= 1 ;
864+ } else if ( ev . deltaMode === WheelEvent . DOM_DELTA_PAGE ) {
865+ amount *= this . _bufferService . rows ;
866+ }
867+ return amount ;
868+ }
828869
829870 /**
830871 * Tells the renderer to refresh terminal content between two rows (inclusive) at the next
0 commit comments