annotate src/testdir/test_signs.vim @ 12451:61450cb2b6a1 v8.0.1105

patch 8.0.1105: match() and matchend() are not tested commit https://github.com/vim/vim/commit/1190cf68e27a123cf9f6fb57897782a3b9f7b810 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 14 14:31:18 2017 +0200 patch 8.0.1105: match() and matchend() are not tested Problem: match() and matchend() are not tested. Solution: Add tests. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/2088)
author Christian Brabandt <cb@256bit.org>
date Thu, 14 Sep 2017 14:45:04 +0200
parents 46e630ac4380
children 03a6aeea2096
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for signs
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 if !has('signs')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 finish
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 endif
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 func Test_sign()
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 new
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call setline(1, ['a', 'b', 'c', 'd'])
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
11 " Define some signs.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
12 " We can specify icons even if not all versions of vim support icons as
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
13 " icon is ignored when not supported. "(not supported)" is shown after
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
14 " the icon name when listing signs.
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 sign define Sign1 text=x
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
16 try
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
17 sign define Sign2 text=xy texthl=Title linehl=Error icon=../../pixmaps/stock_vim_find_help.png
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
18 catch /E255:/
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
19 " ignore error: E255: Couldn't read in sign data!
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
20 " This error can happen when running in gui.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
21 " Some gui like Motif do not support the png icon format.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
22 endtry
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 " Test listing signs.
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 let a=execute('sign list')
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
26 call assert_match("^\nsign Sign1 text=x \nsign Sign2 icon=../../pixmaps/stock_vim_find_help.png .*text=xy linehl=Error texthl=Title$", a)
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 let a=execute('sign list Sign1')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call assert_equal("\nsign Sign1 text=x ", a)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
31 " Split the window to the bottom to verify sign jump will stay in the current window
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
32 " if the buffer is displayed there.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
33 let bn = bufnr('%')
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
34 let wn = winnr()
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
35 exe 'sign place 41 line=3 name=Sign1 buffer=' . bn
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 1
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
37 bot split
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
38 exe 'sign jump 41 buffer=' . bufnr('%')
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
39 call assert_equal('c', getline('.'))
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
40 call assert_equal(3, winnr())
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
41 call assert_equal(bn, bufnr('%'))
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
42 call assert_notequal(wn, winnr())
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
43
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
44 " Create a new buffer and check that ":sign jump" switches to the old buffer.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
45 1
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
46 new foo
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
47 call assert_notequal(bn, bufnr('%'))
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
48 exe 'sign jump 41 buffer=' . bn
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
49 call assert_equal(bn, bufnr('%'))
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 call assert_equal('c', getline('.'))
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
52 " Redraw to make sure that screen redraw with sign gets exercised,
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
53 " with and without 'rightleft'.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
54 if has('rightleft')
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
55 set rightleft
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
56 redraw
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
57 set norightleft
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
58 endif
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
59 redraw
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
61 " Check that we can't change sign.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
62 call assert_fails("exe 'sign place 40 name=Sign1 buffer=' . bufnr('%')", 'E885:')
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
63
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
64 " Check placed signs
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 let a=execute('sign place')
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
66 call assert_equal("\n--- Signs ---\nSigns for [NULL]:\n line=3 id=41 name=Sign1\n", a)
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
68 " Unplace the sign and try jumping to it again should fail.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
69 sign unplace 41
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 1
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
71 call assert_fails("exe 'sign jump 41 buffer=' . bufnr('%')", 'E157:')
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 call assert_equal('a', getline('.'))
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 " Unplace sign on current line.
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
75 exe 'sign place 42 line=4 name=Sign2 buffer=' . bufnr('%')
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 4
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 sign unplace
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 let a=execute('sign place')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 call assert_equal("\n--- Signs ---\n", a)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 " Try again to unplace sign on current line, it should fail this time.
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 call assert_fails('sign unplace', 'E159:')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 " Unplace all signs.
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
85 exe 'sign place 41 line=3 name=Sign1 buffer=' . bufnr('%')
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 sign unplace *
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 let a=execute('sign place')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 call assert_equal("\n--- Signs ---\n", a)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
90 " Check :jump with file=...
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
91 edit foo
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
92 call setline(1, ['A', 'B', 'C', 'D'])
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
93
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
94 try
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
95 sign define Sign3 text=y texthl=DoesNotExist linehl=DoesNotExist icon=doesnotexist.xpm
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
96 catch /E255:/
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
97 " ignore error: E255: it can happens for guis.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
98 endtry
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
99
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
100 let fn = expand('%:p')
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
101 exe 'sign place 43 line=2 name=Sign3 file=' . fn
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
102 edit bar
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
103 call assert_notequal(fn, expand('%:p'))
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
104 exe 'sign jump 43 file=' . fn
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
105 call assert_equal('B', getline('.'))
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
106
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 " After undefining the sign, we should no longer be able to place it.
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 sign undefine Sign1
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 sign undefine Sign2
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
110 sign undefine Sign3
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
111 call assert_fails("exe 'sign place 41 line=3 name=Sign1 buffer=' . bufnr('%')", 'E155:')
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
112 endfunc
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
114 " Undefining placed sign is not recommended.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
115 " Quoting :help sign
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
116 "
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
117 " :sign undefine {name}
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
118 " Deletes a previously defined sign. If signs with this {name}
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
119 " are still placed this will cause trouble.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
120 func Test_sign_undefine_still_placed()
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
121 new foobar
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
122 sign define Sign text=x
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
123 exe 'sign place 41 line=1 name=Sign buffer=' . bufnr('%')
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
124 sign undefine Sign
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
125
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
126 " Listing placed sign should show that sign is deleted.
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
127 let a=execute('sign place')
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
128 call assert_equal("\n--- Signs ---\nSigns for foobar:\n line=1 id=41 name=[Deleted]\n", a)
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
129
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
130 sign unplace 41
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
131 let a=execute('sign place')
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
132 call assert_equal("\n--- Signs ---\n", a)
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 endfunc
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 func Test_sign_completion()
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 sign define Sign1 text=x
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 sign define Sign2 text=y
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 call feedkeys(":sign \<C-A>\<C-B>\"\<CR>", 'tx')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 call assert_equal('"sign define jump list place undefine unplace', @:)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 call feedkeys(":sign define Sign \<C-A>\<C-B>\"\<CR>", 'tx')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 call assert_equal('"sign define Sign icon= linehl= text= texthl=', @:)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145 call feedkeys(":sign define Sign linehl=Spell\<C-A>\<C-B>\"\<CR>", 'tx')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 call assert_equal('"sign define Sign linehl=SpellBad SpellCap SpellLocal SpellRare', @:)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147
10044
46e630ac4380 commit https://github.com/vim/vim/commit/64cefedfc834aa4dac54ae5f91ccbc04e2d56bc5
Christian Brabandt <cb@256bit.org>
parents: 9902
diff changeset
148 call writefile(['foo'], 'XsignOne')
46e630ac4380 commit https://github.com/vim/vim/commit/64cefedfc834aa4dac54ae5f91ccbc04e2d56bc5
Christian Brabandt <cb@256bit.org>
parents: 9902
diff changeset
149 call writefile(['bar'], 'XsignTwo')
46e630ac4380 commit https://github.com/vim/vim/commit/64cefedfc834aa4dac54ae5f91ccbc04e2d56bc5
Christian Brabandt <cb@256bit.org>
parents: 9902
diff changeset
150 call feedkeys(":sign define Sign icon=Xsig\<C-A>\<C-B>\"\<CR>", 'tx')
46e630ac4380 commit https://github.com/vim/vim/commit/64cefedfc834aa4dac54ae5f91ccbc04e2d56bc5
Christian Brabandt <cb@256bit.org>
parents: 9902
diff changeset
151 call assert_equal('"sign define Sign icon=XsignOne XsignTwo', @:)
46e630ac4380 commit https://github.com/vim/vim/commit/64cefedfc834aa4dac54ae5f91ccbc04e2d56bc5
Christian Brabandt <cb@256bit.org>
parents: 9902
diff changeset
152 call delete('XsignOne')
46e630ac4380 commit https://github.com/vim/vim/commit/64cefedfc834aa4dac54ae5f91ccbc04e2d56bc5
Christian Brabandt <cb@256bit.org>
parents: 9902
diff changeset
153 call delete('XsignTwo')
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
154
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 call feedkeys(":sign undefine \<C-A>\<C-B>\"\<CR>", 'tx')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 call assert_equal('"sign undefine Sign1 Sign2', @:)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 call feedkeys(":sign place 1 \<C-A>\<C-B>\"\<CR>", 'tx')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 call assert_equal('"sign place 1 buffer= file= line= name=', @:)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 call feedkeys(":sign place 1 name=\<C-A>\<C-B>\"\<CR>", 'tx')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 call assert_equal('"sign place 1 name=Sign1 Sign2', @:)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
163
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
164 call feedkeys(":sign unplace 1 \<C-A>\<C-B>\"\<CR>", 'tx')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 call assert_equal('"sign unplace 1 buffer= file=', @:)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 call feedkeys(":sign list \<C-A>\<C-B>\"\<CR>", 'tx')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 call assert_equal('"sign list Sign1 Sign2', @:)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 call feedkeys(":sign jump 1 \<C-A>\<C-B>\"\<CR>", 'tx')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 call assert_equal('"sign jump 1 buffer= file=', @:)
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 sign undefine Sign1
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 sign undefine Sign2
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 endfunc
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 func Test_sign_invalid_commands()
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 call assert_fails('sign', 'E471:')
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
179 call assert_fails('sign jump', 'E471:')
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 call assert_fails('sign xxx', 'E160:')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 call assert_fails('sign define', 'E156:')
9838
66f1cf5dd385 commit https://github.com/vim/vim/commit/446a973ce3ce4988607292c0e6345db788f12c7b
Christian Brabandt <cb@256bit.org>
parents: 9816
diff changeset
182 call assert_fails('sign define Sign1 xxx', 'E475:')
9816
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 call assert_fails('sign undefine', 'E156:')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 call assert_fails('sign list xxx', 'E155:')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 call assert_fails('sign place 1 buffer=', 'E158:')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 call assert_fails('sign define Sign2 text=', 'E239:')
74990ddf0813 commit https://github.com/vim/vim/commit/09de17536dd84e43aed7a575183e320e8d980b68
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 endfunc
9902
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
188
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
189 func Test_sign_delete_buffer()
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
190 new
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
191 sign define Sign text=x
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
192 let bufnr = bufnr('%')
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
193 new
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
194 exe 'bd ' . bufnr
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
195 exe 'sign place 61 line=3 name=Sign buffer=' . bufnr
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
196 call assert_fails('sign jump 61 buffer=' . bufnr, 'E934:')
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
197 sign unplace 61
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
198 sign undefine Sign
5a667a3a3743 commit https://github.com/vim/vim/commit/bfd096d02087a10e8e2f4bdfb74e0435506fa8bb
Christian Brabandt <cb@256bit.org>
parents: 9838
diff changeset
199 endfunc