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