@@ -157,6 +157,7 @@ describe("GhosttyTerminalSurface visibility", () => {
157157 "window" ,
158158 Object . assign ( new EventTarget ( ) , {
159159 devicePixelRatio : 1 ,
160+ innerHeight : 104 ,
160161 requestAnimationFrame : requestFrame ,
161162 cancelAnimationFrame : ( id : number ) => frames . delete ( id ) ,
162163 setTimeout,
@@ -207,11 +208,12 @@ describe("GhosttyTerminalSurface visibility", () => {
207208 buttons : number ,
208209 modifiers : boolean | Partial < Pick < MouseEvent , "ctrlKey" | "metaKey" | "shiftKey" > > = { } ,
209210 button = 0 ,
211+ clientY = 5 ,
210212 ) {
211213 canvas . dispatchEvent (
212214 Object . assign ( new Event ( type , { cancelable : true } ) , {
213215 clientX,
214- clientY : 5 ,
216+ clientY,
215217 pointerId : 1 ,
216218 button,
217219 buttons,
@@ -604,6 +606,28 @@ describe("GhosttyTerminalSurface visibility", () => {
604606 expect ( harness . renderedSnapshot . rowData [ 0 ] ?. cells . some ( ( cell ) => cell . selected ) ) . toBe ( false ) ;
605607 } ) ;
606608
609+ it ( "scrolls a selection drag held at the terminal edge, even when the window ends there" , async ( ) => {
610+ const harness = createHarness ( ) ;
611+ const surface = await harness . create ( ) ;
612+ surface . write ( Array . from ( { length : 40 } , ( _ , index ) => `line ${ index } ` ) . join ( "\r\n" ) ) ;
613+ harness . flushFrame ( ) ;
614+ const latest = harness . renderedSnapshot . rowData [ 0 ] ?. text ;
615+
616+ harness . pointer ( "pointerdown" , 5 , 1 , { } , 0 , 50 ) ;
617+ harness . pointer ( "pointermove" , 5 , 1 , { } , 0 , 1 ) ;
618+ vi . advanceTimersByTime ( 400 ) ;
619+ harness . flushFrame ( ) ;
620+ expect ( surface . isAtBottom ( ) ) . toBe ( false ) ;
621+
622+ harness . pointer ( "pointermove" , 5 , 1 , { } , 0 , 103 ) ;
623+ vi . advanceTimersByTime ( 2_000 ) ;
624+ harness . pointer ( "pointerup" , 5 , 0 , { } , 0 , 103 ) ;
625+ harness . flushFrame ( ) ;
626+ expect ( surface . isAtBottom ( ) ) . toBe ( true ) ;
627+ expect ( harness . renderedSnapshot . rowData [ 0 ] ?. text ) . toBe ( latest ) ;
628+ expect ( surface . getSelection ( ) ) . not . toBe ( "" ) ;
629+ } ) ;
630+
607631 it ( "pastes the terminal selection, and only that, on a Linux middle click" , async ( ) => {
608632 const harness = createHarness ( ) ;
609633 const readText = vi . fn ( async ( ) => "clipboard text" ) ;
0 commit comments