@@ -117,6 +117,27 @@ func TestUpdatedCursorAndOrigin(t *testing.T) {
117
117
}
118
118
}
119
119
120
+ func TestAutoRenderingHyperlinks (t * testing.T ) {
121
+ v := NewView ("name" , 0 , 0 , 10 , 10 , OutputNormal )
122
+ v .AutoRenderHyperLinks = true
123
+
124
+ v .writeRunes ([]rune ("htt" ))
125
+ // No hyperlinks are generated for incomplete URLs
126
+ assert .Equal (t , "" , v .lines [0 ][0 ].hyperlink )
127
+ // Writing more characters to the same line makes the link complete (even
128
+ // though we didn't see a newline yet)
129
+ v .writeRunes ([]rune ("ps://example.com" ))
130
+ assert .Equal (t , "https://example.com" , v .lines [0 ][0 ].hyperlink )
131
+
132
+ v .Clear ()
133
+ // Valid but incomplete URL
134
+ v .writeRunes ([]rune ("https://exa" ))
135
+ assert .Equal (t , "https://exa" , v .lines [0 ][0 ].hyperlink )
136
+ // Writing more characters to the same fixes the link
137
+ v .writeRunes ([]rune ("mple.com" ))
138
+ assert .Equal (t , "https://example.com" , v .lines [0 ][0 ].hyperlink )
139
+ }
140
+
120
141
func TestContainsColoredText (t * testing.T ) {
121
142
hexColor := func (text string , hexStr string ) []cell {
122
143
cells := make ([]cell , len (text ))
0 commit comments