@@ -12,7 +12,6 @@ import {
1212 isTerminalCompositionCommitInput ,
1313 isTerminalCompositionKey ,
1414 isTerminalCopyShortcut ,
15- isTerminalLinkPointerGesture ,
1615 isTerminalPasteShortcut ,
1716 loadTerminalFontFamily ,
1817 primeTerminalCopyInput ,
@@ -168,14 +167,15 @@ describe("GhosttyTerminalSurface visibility", () => {
168167 resize ( ) {
169168 for ( const callback of resizeCallbacks ) callback ( ) ;
170169 } ,
171- pointer ( type : string , clientX : number , buttons : number ) {
170+ pointer ( type : string , clientX : number , buttons : number , shiftKey = false ) {
172171 canvas . dispatchEvent (
173172 Object . assign ( new Event ( type , { cancelable : true } ) , {
174173 clientX,
175174 clientY : 5 ,
176175 pointerId : 1 ,
177176 button : 0 ,
178177 buttons,
178+ shiftKey,
179179 } ) ,
180180 ) ;
181181 } ,
@@ -280,6 +280,84 @@ describe("GhosttyTerminalSurface visibility", () => {
280280 expect ( harness . renderedSnapshot . rowData [ 0 ] ?. cells . some ( ( cell ) => cell . selected ) ) . toBe ( false ) ;
281281 } ) ;
282282
283+ it ( "starts a selection when dragging from a link" , async ( ) => {
284+ const harness = createHarness ( ) ;
285+ const onLinkActivate = vi . fn ( ) ;
286+ const surface = await harness . create ( { onLinkActivate } ) ;
287+ surface . write ( "https://example.com" ) ;
288+ harness . flushFrame ( ) ;
289+
290+ harness . pointer ( "pointerdown" , 5 , 1 ) ;
291+ harness . pointer ( "pointermove" , 37 , 1 ) ;
292+ harness . pointer ( "pointerup" , 37 , 0 ) ;
293+
294+ expect ( onLinkActivate ) . not . toHaveBeenCalled ( ) ;
295+ expect ( surface . getSelection ( ) ) . toBe ( "https" ) ;
296+ } ) ;
297+
298+ it ( "keeps a link click active through slight pointer movement" , async ( ) => {
299+ const harness = createHarness ( ) ;
300+ const onLinkActivate = vi . fn ( ) ;
301+ const surface = await harness . create ( { onLinkActivate } ) ;
302+ surface . write ( "https://example.com" ) ;
303+ harness . flushFrame ( ) ;
304+
305+ harness . pointer ( "pointerdown" , 5 , 1 ) ;
306+ harness . pointer ( "pointermove" , 6 , 1 ) ;
307+ harness . pointer ( "pointerup" , 6 , 0 ) ;
308+
309+ expect ( onLinkActivate ) . toHaveBeenCalledOnce ( ) ;
310+ } ) ;
311+
312+ it ( "uses repeated link clicks for word and line selection" , async ( ) => {
313+ const harness = createHarness ( ) ;
314+ const onLinkActivate = vi . fn ( ) ;
315+ const surface = await harness . create ( { onLinkActivate } ) ;
316+ surface . write ( "https://example.com tail" ) ;
317+ harness . flushFrame ( ) ;
318+
319+ harness . pointer ( "pointerdown" , 5 , 1 ) ;
320+ harness . pointer ( "pointerup" , 5 , 0 ) ;
321+ harness . pointer ( "pointerdown" , 5 , 1 ) ;
322+ harness . pointer ( "pointerup" , 5 , 0 ) ;
323+ expect ( onLinkActivate ) . toHaveBeenCalledOnce ( ) ;
324+ expect ( surface . getSelection ( ) ) . not . toBe ( "" ) ;
325+
326+ harness . pointer ( "pointerdown" , 5 , 1 ) ;
327+ harness . pointer ( "pointerup" , 5 , 0 ) ;
328+ expect ( onLinkActivate ) . toHaveBeenCalledOnce ( ) ;
329+ expect ( surface . getSelection ( ) ) . toBe ( "https://example.com tail" ) ;
330+ } ) ;
331+
332+ it ( "uses Shift drags over links for selection" , async ( ) => {
333+ const harness = createHarness ( ) ;
334+ const onLinkActivate = vi . fn ( ) ;
335+ const surface = await harness . create ( { onLinkActivate } ) ;
336+ surface . write ( "https://example.com" ) ;
337+ harness . flushFrame ( ) ;
338+
339+ harness . pointer ( "pointerdown" , 5 , 1 , true ) ;
340+ harness . pointer ( "pointermove" , 37 , 1 , true ) ;
341+ harness . pointer ( "pointerup" , 37 , 0 , true ) ;
342+ expect ( onLinkActivate ) . not . toHaveBeenCalled ( ) ;
343+ expect ( surface . getSelection ( ) ) . toBe ( "https" ) ;
344+ } ) ;
345+
346+ it ( "does not activate a link replaced before pointer release" , async ( ) => {
347+ const harness = createHarness ( ) ;
348+ const onLinkActivate = vi . fn ( ) ;
349+ const surface = await harness . create ( { onLinkActivate } ) ;
350+ surface . write ( "https://first.example" ) ;
351+ harness . flushFrame ( ) ;
352+
353+ harness . pointer ( "pointerdown" , 5 , 1 ) ;
354+ surface . write ( "\x1b[2J\x1b[Hhttps://second.example" ) ;
355+ harness . flushFrame ( ) ;
356+ harness . pointer ( "pointerup" , 5 , 0 ) ;
357+
358+ expect ( onLinkActivate ) . not . toHaveBeenCalled ( ) ;
359+ } ) ;
360+
283361 it ( "stops zero-size mounts and repaints when the same size returns" , async ( ) => {
284362 const harness = createHarness ( ) ;
285363 const surface = await harness . create ( ) ;
@@ -890,19 +968,6 @@ describe("terminalWheelArrowData", () => {
890968 } ) ;
891969} ) ;
892970
893- describe ( "isTerminalLinkPointerGesture" , ( ) => {
894- it ( "uses Command on macOS and Control elsewhere" , ( ) => {
895- expect ( isTerminalLinkPointerGesture ( { ctrlKey : false , metaKey : true } , "MacIntel" ) ) . toBe ( true ) ;
896- expect ( isTerminalLinkPointerGesture ( { ctrlKey : true , metaKey : false } , "MacIntel" ) ) . toBe ( false ) ;
897- expect ( isTerminalLinkPointerGesture ( { ctrlKey : true , metaKey : false } , "Linux x86_64" ) ) . toBe (
898- true ,
899- ) ;
900- expect ( isTerminalLinkPointerGesture ( { ctrlKey : false , metaKey : true } , "Linux x86_64" ) ) . toBe (
901- false ,
902- ) ;
903- } ) ;
904- } ) ;
905-
906971describe ( "advanceTerminalSelectionClickSequence" , ( ) => {
907972 it ( "recognizes stationary double and triple pointer presses without PointerEvent.detail" , ( ) => {
908973 const first = advanceTerminalSelectionClickSequence ( null , {
0 commit comments