@@ -13,10 +13,13 @@ import {
1313 isTerminalPasteShortcut ,
1414 shouldBlinkTerminalCursor ,
1515 shouldReportTerminalMouse ,
16+ shouldShowTerminalLinkHover ,
17+ terminalGridCellAt ,
1618 terminalScrollbarGeometry ,
1719 terminalScrollbarOffsetAtPointer ,
1820 terminalLinkAtColumn ,
1921 terminalLinkAtPosition ,
22+ terminalLinkAtPositionWithRange ,
2023 terminalContentOriginY ,
2124 terminalFontFamily ,
2225 fittedTerminalFontSize ,
@@ -56,6 +59,32 @@ describe("isTerminalAltGraphText", () => {
5659 } ) ;
5760} ) ;
5861
62+ describe ( "terminalGridCellAt" , ( ) => {
63+ const options = {
64+ bounds : { left : 100 , top : 200 } ,
65+ cols : 3 ,
66+ rows : 2 ,
67+ metrics : { width : 10 , height : 20 } ,
68+ padding : 4 ,
69+ originY : 24 ,
70+ } ;
71+
72+ it ( "maps points inside the rendered grid without clamping its padding" , ( ) => {
73+ expect ( terminalGridCellAt ( { ...options , clientX : 104 , clientY : 224 } ) ) . toEqual ( {
74+ x : 0 ,
75+ y : 0 ,
76+ } ) ;
77+ expect ( terminalGridCellAt ( { ...options , clientX : 133 , clientY : 263 } ) ) . toEqual ( {
78+ x : 2 ,
79+ y : 1 ,
80+ } ) ;
81+ expect ( terminalGridCellAt ( { ...options , clientX : 103 , clientY : 224 } ) ) . toBeNull ( ) ;
82+ expect ( terminalGridCellAt ( { ...options , clientX : 104 , clientY : 223 } ) ) . toBeNull ( ) ;
83+ expect ( terminalGridCellAt ( { ...options , clientX : 134 , clientY : 224 } ) ) . toBeNull ( ) ;
84+ expect ( terminalGridCellAt ( { ...options , clientX : 104 , clientY : 264 } ) ) . toBeNull ( ) ;
85+ } ) ;
86+ } ) ;
87+
5988describe ( "shouldBlinkTerminalCursor" , ( ) => {
6089 const blinking = {
6190 focused : true ,
@@ -99,6 +128,10 @@ describe("terminalLinkAtColumn", () => {
99128 expect ( terminalLinkAtColumn ( row , 2 ) ) . toBe ( "https://t3.codes" ) ;
100129 expect ( terminalLinkAtColumn ( row , cells . length - 1 ) ) . toBe ( "https://t3.codes" ) ;
101130 expect ( terminalLinkAtColumn ( row , 0 ) ) . toBeNull ( ) ;
131+ expect ( terminalLinkAtPositionWithRange ( [ row ] , 0 , 8 ) ?. range ) . toEqual ( {
132+ start : { x : 2 , y : 0 } ,
133+ end : { x : cells . length - 1 , y : 0 } ,
134+ } ) ;
102135 } ) ;
103136
104137 it ( "uses shared path matching and reconstructs soft-wrapped links" , ( ) => {
@@ -119,6 +152,13 @@ describe("terminalLinkAtColumn", () => {
119152 expect ( terminalLinkAtPosition ( rows , 1 , 4 ) ) . toBe ( "https://example.com/reference" ) ;
120153 expect ( terminalLinkAtPosition ( rows , 2 , 2 ) ) . toBe ( "~/project/file" ) ;
121154 expect ( terminalLinkAtPosition ( rows , 3 , 4 ) ) . toBe ( "C:\\repo\\file.ts" ) ;
155+ expect ( terminalLinkAtPositionWithRange ( rows , 1 , 4 ) ) . toEqual ( {
156+ text : "https://example.com/reference" ,
157+ range : {
158+ start : { x : 0 , y : 0 } ,
159+ end : { x : 12 , y : 1 } ,
160+ } ,
161+ } ) ;
122162 } ) ;
123163
124164 it ( "refuses links truncated at the viewport edges instead of mis-resolving" , ( ) => {
@@ -245,6 +285,13 @@ describe("application mouse reporting", () => {
245285 it ( "maps browser buttons to Ghostty's button enum" , ( ) => {
246286 expect ( [ 0 , 1 , 2 , 3 , 4 , 5 ] . map ( ghosttyMouseButton ) ) . toEqual ( [ 1 , 3 , 2 , 4 , 5 , null ] ) ;
247287 } ) ;
288+
289+ it ( "only shows link hover during mouse tracking when the link modifier is held" , ( ) => {
290+ expect ( shouldShowTerminalLinkHover ( false , false ) ) . toBe ( true ) ;
291+ expect ( shouldShowTerminalLinkHover ( false , true ) ) . toBe ( true ) ;
292+ expect ( shouldShowTerminalLinkHover ( true , false ) ) . toBe ( false ) ;
293+ expect ( shouldShowTerminalLinkHover ( true , true ) ) . toBe ( true ) ;
294+ } ) ;
248295} ) ;
249296
250297describe ( "terminal font resolution" , ( ) => {
0 commit comments