annotate src/testdir/test_gf.vim @ 11436:69b52a770b29 v8.0.0602

patch 8.0.0602: when gF fails to edit the file the cursor still moves commit https://github.com/vim/vim/commit/2a79ed293c077ba791db962f0e121cf97ba4f7a7 Author: Bram Moolenaar <Bram@vim.org> Date: Wed May 24 09:51:39 2017 +0200 patch 8.0.0602: when gF fails to edit the file the cursor still moves Problem: When gF fails to edit the file the cursor still moves to the found line number. Solution: Check the return value of do_ecmd(). (Michael Hwang)
author Christian Brabandt <cb@256bit.org>
date Wed, 24 May 2017 10:00:03 +0200
parents eb9a7296ae9f
children 53f6d97b4e77
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",
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 \ "fourth test for URL:\\\\machine.name\\tmp\\vimtest2d, and other text"
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 \ ])
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call cursor(1,1)
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call search("^first")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 call search("tmp")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 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
16 call search("^second")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call search("URL")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 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
19 if has("ebcdic")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 set isf=@,240-249,/,.,-,_,+,,,$,:,~,\
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 else
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 set isf=@,48-57,/,.,-,_,+,,,$,:,~,\
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 endif
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 call search("^third")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 call search("name")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 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
27 call search("^fourth")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 call search("URL")
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 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
30
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 set isf&vim
eb9a7296ae9f commit https://github.com/vim/vim/commit/53f1673cd909eb1c809c6a9086e3d104a0df9bed
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 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
33 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
34
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
35 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
36 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
37 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
38 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
39 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
40 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
41 call setline(1, ['one', 'Xfile:3', 'three'])
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 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
43 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
44 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
45 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
46 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
47 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
48 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
49
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 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
51 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
52 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
53 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
54 endfunc