annotate src/testdir/test_gf.vim @ 13103:788d01164bb2 v8.0.1426

patch 8.0.1426: "gf" and <cfile> don't accept ? and & in URL commit https://github.com/vim/vim/commit/9e3dfc650190e96739abc004eb9948afa68136b4 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 25 14:29:18 2017 +0100 patch 8.0.1426: "gf" and <cfile> don't accept ? and & in URL Problem: "gf" and <cfile> don't accept ? and & in URL. (Dmitrii Tcyganok) Solution: Check for a URL and allow for extra characters. (closes https://github.com/vim/vim/issues/2493)
author Christian Brabandt <cb@256bit.org>
date Mon, 25 Dec 2017 14:30:06 +0100
parents f9f2e9aa884c
children 58610c4d785c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10145
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " This is a test if a URL is recognized by "gf", with the cursor before and
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " after the "://". Also test ":\\".
11436
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
4 func Test_gf_url()
10145
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 enew!
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 call append(0, [
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 \ "first test for URL://machine.name/tmp/vimtest2a and other text",
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 \ "second test for URL://machine.name/tmp/vimtest2b. And other text",
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 \ "third test for URL:\\\\machine.name\\vimtest2c and other text",
13103
788d01164bb2 patch 8.0.1426: "gf" and <cfile> don't accept ? and & in URL
Christian Brabandt <cb@256bit.org>
parents: 11440
diff changeset
10 \ "fourth test for URL:\\\\machine.name\\tmp\\vimtest2d, and other text",
788d01164bb2 patch 8.0.1426: "gf" and <cfile> don't accept ? and & in URL
Christian Brabandt <cb@256bit.org>
parents: 11440
diff changeset
11 \ "fifth test for URL://machine.name/tmp?q=vim&opt=yes and other text",
10145
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 \ ])
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call cursor(1,1)
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 call search("^first")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call search("tmp")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 call assert_equal("URL://machine.name/tmp/vimtest2a", expand("<cfile>"))
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call search("^second")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call search("URL")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call assert_equal("URL://machine.name/tmp/vimtest2b", expand("<cfile>"))
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 if has("ebcdic")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 set isf=@,240-249,/,.,-,_,+,,,$,:,~,\
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 else
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 set isf=@,48-57,/,.,-,_,+,,,$,:,~,\
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 endif
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call search("^third")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 call search("name")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call assert_equal("URL:\\\\machine.name\\vimtest2c", expand("<cfile>"))
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 call search("^fourth")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call search("URL")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call assert_equal("URL:\\\\machine.name\\tmp\\vimtest2d", expand("<cfile>"))
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31
13103
788d01164bb2 patch 8.0.1426: "gf" and <cfile> don't accept ? and & in URL
Christian Brabandt <cb@256bit.org>
parents: 11440
diff changeset
32 call search("^fifth")
788d01164bb2 patch 8.0.1426: "gf" and <cfile> don't accept ? and & in URL
Christian Brabandt <cb@256bit.org>
parents: 11440
diff changeset
33 call search("URL")
788d01164bb2 patch 8.0.1426: "gf" and <cfile> don't accept ? and & in URL
Christian Brabandt <cb@256bit.org>
parents: 11440
diff changeset
34 call assert_equal("URL://machine.name/tmp?q=vim&opt=yes", expand("<cfile>"))
788d01164bb2 patch 8.0.1426: "gf" and <cfile> don't accept ? and & in URL
Christian Brabandt <cb@256bit.org>
parents: 11440
diff changeset
35
10145
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 set isf&vim
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 enew!
11436
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
38 endfunc
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
39
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
40 func Test_gF()
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
41 new
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
42 call setline(1, ['111', '222', '333', '444'])
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
43 w! Xfile
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
44 close
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
45 new
11440
f9f2e9aa884c patch 8.0.0604: gF test fails still on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11438
diff changeset
46 set isfname-=:
f9f2e9aa884c patch 8.0.0604: gF test fails still on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11438
diff changeset
47 call setline(1, ['one', 'Xfile:3', 'three'])
11436
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
48 2
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
49 call assert_fails('normal gF', 'E37:')
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
50 call assert_equal(2, getcurpos()[1])
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
51 w! Xfile2
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
52 normal gF
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
53 call assert_equal('Xfile', bufname('%'))
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
54 call assert_equal(3, getcurpos()[1])
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
55
11440
f9f2e9aa884c patch 8.0.0604: gF test fails still on MS-Windows
Christian Brabandt <cb@256bit.org>
parents: 11438
diff changeset
56 set isfname&
11436
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
57 call delete('Xfile')
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
58 call delete('Xfile2')
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
59 bwipe Xfile
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
60 bwipe Xfile2
69b52a770b29 patch 8.0.0602: when gF fails to edit the file the cursor still moves
Christian Brabandt <cb@256bit.org>
parents: 10145
diff changeset
61 endfunc