Bram Moolenaar | 53f1673 | 2016-09-07 20:46:39 +0200 | [diff] [blame] | 1 | |
| 2 | " This is a test if a URL is recognized by "gf", with the cursor before and |
| 3 | " after the "://". Also test ":\\". |
Bram Moolenaar | 2a79ed2 | 2017-05-24 09:51:39 +0200 | [diff] [blame] | 4 | func Test_gf_url() |
Bram Moolenaar | 53f1673 | 2016-09-07 20:46:39 +0200 | [diff] [blame] | 5 | enew! |
| 6 | call append(0, [ |
| 7 | \ "first test for URL://machine.name/tmp/vimtest2a and other text", |
| 8 | \ "second test for URL://machine.name/tmp/vimtest2b. And other text", |
| 9 | \ "third test for URL:\\\\machine.name\\vimtest2c and other text", |
Bram Moolenaar | 9e3dfc6 | 2017-12-25 14:29:18 +0100 | [diff] [blame] | 10 | \ "fourth test for URL:\\\\machine.name\\tmp\\vimtest2d, and other text", |
| 11 | \ "fifth test for URL://machine.name/tmp?q=vim&opt=yes and other text", |
Bram Moolenaar | 53f1673 | 2016-09-07 20:46:39 +0200 | [diff] [blame] | 12 | \ ]) |
| 13 | call cursor(1,1) |
| 14 | call search("^first") |
| 15 | call search("tmp") |
| 16 | call assert_equal("URL://machine.name/tmp/vimtest2a", expand("<cfile>")) |
| 17 | call search("^second") |
| 18 | call search("URL") |
| 19 | call assert_equal("URL://machine.name/tmp/vimtest2b", expand("<cfile>")) |
| 20 | if has("ebcdic") |
| 21 | set isf=@,240-249,/,.,-,_,+,,,$,:,~,\ |
| 22 | else |
| 23 | set isf=@,48-57,/,.,-,_,+,,,$,:,~,\ |
| 24 | endif |
| 25 | call search("^third") |
| 26 | call search("name") |
| 27 | call assert_equal("URL:\\\\machine.name\\vimtest2c", expand("<cfile>")) |
| 28 | call search("^fourth") |
| 29 | call search("URL") |
| 30 | call assert_equal("URL:\\\\machine.name\\tmp\\vimtest2d", expand("<cfile>")) |
| 31 | |
Bram Moolenaar | 9e3dfc6 | 2017-12-25 14:29:18 +0100 | [diff] [blame] | 32 | call search("^fifth") |
| 33 | call search("URL") |
| 34 | call assert_equal("URL://machine.name/tmp?q=vim&opt=yes", expand("<cfile>")) |
| 35 | |
Bram Moolenaar | 53f1673 | 2016-09-07 20:46:39 +0200 | [diff] [blame] | 36 | set isf&vim |
| 37 | enew! |
Bram Moolenaar | 2a79ed2 | 2017-05-24 09:51:39 +0200 | [diff] [blame] | 38 | endfunc |
| 39 | |
| 40 | func Test_gF() |
| 41 | new |
| 42 | call setline(1, ['111', '222', '333', '444']) |
| 43 | w! Xfile |
| 44 | close |
| 45 | new |
Bram Moolenaar | 712598f | 2017-05-24 10:42:37 +0200 | [diff] [blame] | 46 | set isfname-=: |
| 47 | call setline(1, ['one', 'Xfile:3', 'three']) |
Bram Moolenaar | 2a79ed2 | 2017-05-24 09:51:39 +0200 | [diff] [blame] | 48 | 2 |
| 49 | call assert_fails('normal gF', 'E37:') |
| 50 | call assert_equal(2, getcurpos()[1]) |
| 51 | w! Xfile2 |
| 52 | normal gF |
| 53 | call assert_equal('Xfile', bufname('%')) |
| 54 | call assert_equal(3, getcurpos()[1]) |
| 55 | |
Bram Moolenaar | 712598f | 2017-05-24 10:42:37 +0200 | [diff] [blame] | 56 | set isfname& |
Bram Moolenaar | 2a79ed2 | 2017-05-24 09:51:39 +0200 | [diff] [blame] | 57 | call delete('Xfile') |
| 58 | call delete('Xfile2') |
| 59 | bwipe Xfile |
| 60 | bwipe Xfile2 |
| 61 | endfunc |