Mercurial > vim
annotate src/testdir/test_gf.vim @ 13060:1bdc12630fc0 v8.0.1405
patch 8.0.1405: duplicated code for getting a typed character
commit https://github.com/vim/vim/commit/c9e649ae816cdff0d1da8a97d40e695c6d3991bd
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 18 18:14:47 2017 +0100
patch 8.0.1405: duplicated code for getting a typed character
Problem: Duplicated code for getting a typed character. CursorHold is
called too often in the GUI. (lilydjwg)
Solution: Refactor code to move code up from mch_inchar(). Don't fire
CursorHold if feedkeys() was used. (closes #2451)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 18 Dec 2017 18:15:05 +0100 |
parents | f9f2e9aa884c |
children | 788d01164bb2 |
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 |
11440
f9f2e9aa884c
patch 8.0.0604: gF test fails still on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11438
diff
changeset
|
41 set isfname-=: |
f9f2e9aa884c
patch 8.0.0604: gF test fails still on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11438
diff
changeset
|
42 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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 |
11440
f9f2e9aa884c
patch 8.0.0604: gF test fails still on MS-Windows
Christian Brabandt <cb@256bit.org>
parents:
11438
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 endfunc |