1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0679
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0679
Problem: Sign functions do not take buffer argument as documented.
Solution: Use get_buf_tv(). (Yegappan Lakshmanan, closes #3755)
Files: src/evalfunc.c, src/testdir/test_signs.vim
*** ../vim-8.1.0678/src/evalfunc.c 2019-01-01 13:20:05.940711222 +0100
--- src/evalfunc.c 2019-01-02 13:37:14.702974769 +0100
***************
*** 11365,11371 ****
if (argvars[0].v_type != VAR_UNKNOWN)
{
// get signs placed in this buffer
! buf = find_buffer(&argvars[0]);
if (buf == NULL)
{
EMSG2(_("E158: Invalid buffer name: %s"),
--- 11365,11371 ----
if (argvars[0].v_type != VAR_UNKNOWN)
{
// get signs placed in this buffer
! buf = get_buf_tv(&argvars[0], FALSE);
if (buf == NULL)
{
EMSG2(_("E158: Invalid buffer name: %s"),
***************
*** 11457,11463 ****
goto cleanup;
// Buffer to place the sign
! buf = find_buffer(&argvars[3]);
if (buf == NULL)
{
EMSG2(_("E158: Invalid buffer name: %s"), tv_get_string(&argvars[2]));
--- 11457,11463 ----
goto cleanup;
// Buffer to place the sign
! buf = get_buf_tv(&argvars[3], FALSE);
if (buf == NULL)
{
EMSG2(_("E158: Invalid buffer name: %s"), tv_get_string(&argvars[2]));
***************
*** 11566,11572 ****
if ((di = dict_find(dict, (char_u *)"buffer", -1)) != NULL)
{
! buf = find_buffer(&di->di_tv);
if (buf == NULL)
{
EMSG2(_("E158: Invalid buffer name: %s"),
--- 11566,11572 ----
if ((di = dict_find(dict, (char_u *)"buffer", -1)) != NULL)
{
! buf = get_buf_tv(&di->di_tv, FALSE);
if (buf == NULL)
{
EMSG2(_("E158: Invalid buffer name: %s"),
*** ../vim-8.1.0678/src/testdir/test_signs.vim 2018-12-31 22:02:24.077890554 +0100
--- src/testdir/test_signs.vim 2019-01-02 13:37:14.702974769 +0100
***************
*** 32,38 ****
" current window if the buffer is displayed there.
let bn = bufnr('%')
let wn = winnr()
! exe 'sign place 41 line=3 name=Sign1 buffer=' . bn
1
bot split
exe 'sign jump 41 buffer=' . bufnr('%')
--- 32,38 ----
" current window if the buffer is displayed there.
let bn = bufnr('%')
let wn = winnr()
! exe 'sign place 41 line=3 name=Sign1 buffer=' . bn
1
bot split
exe 'sign jump 41 buffer=' . bufnr('%')
***************
*** 77,83 ****
sign unplace
let a=execute('sign place')
call assert_equal("\n--- Signs ---\n", a)
!
" Try again to unplace sign on current line, it should fail this time.
call assert_fails('sign unplace', 'E159:')
--- 77,83 ----
sign unplace
let a=execute('sign place')
call assert_equal("\n--- Signs ---\n", a)
!
" Try again to unplace sign on current line, it should fail this time.
call assert_fails('sign unplace', 'E159:')
***************
*** 386,396 ****
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
\ 'priority' : 10}]}],
! \ sign_getplaced('Xsign', {'lnum' : 20}))
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
\ 'priority' : 10}]}],
! \ sign_getplaced('Xsign', {'id' : 10}))
" Tests for invalid arguments to sign_place()
call assert_fails('call sign_place([], "", "mySign", 1)', 'E745:')
--- 386,396 ----
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
\ 'priority' : 10}]}],
! \ sign_getplaced('%', {'lnum' : 20}))
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
\ 'priority' : 10}]}],
! \ sign_getplaced('', {'id' : 10}))
" Tests for invalid arguments to sign_place()
call assert_fails('call sign_place([], "", "mySign", 1)', 'E745:')
***************
*** 407,413 ****
\ {"lnum" : 30})', 'E730:')
call assert_fails('call sign_place(5, "", "sign1", "abcxyz.xxx",
\ {"lnum" : 10})', 'E158:')
! call assert_fails('call sign_place(5, "", "sign1", "", {"lnum" : 10})',
\ 'E158:')
call assert_fails('call sign_place(5, "", "sign1", [], {"lnum" : 10})',
\ 'E158:')
--- 407,413 ----
\ {"lnum" : 30})', 'E730:')
call assert_fails('call sign_place(5, "", "sign1", "abcxyz.xxx",
\ {"lnum" : 10})', 'E158:')
! call assert_fails('call sign_place(5, "", "sign1", "@", {"lnum" : 10})',
\ 'E158:')
call assert_fails('call sign_place(5, "", "sign1", [], {"lnum" : 10})',
\ 'E158:')
***************
*** 429,435 ****
\ 'priority' : 10}]}],
\ sign_getplaced())
call assert_fails("call sign_getplaced('dummy.sign')", 'E158:')
! call assert_fails('call sign_getplaced("")', 'E158:')
call assert_fails('call sign_getplaced(-1)', 'E158:')
call assert_fails('call sign_getplaced("Xsign", [])', 'E715:')
call assert_equal([{'bufnr' : bufnr(''), 'signs' : []}],
--- 429,435 ----
\ 'priority' : 10}]}],
\ sign_getplaced())
call assert_fails("call sign_getplaced('dummy.sign')", 'E158:')
! call assert_fails('call sign_getplaced("&")', 'E158:')
call assert_fails('call sign_getplaced(-1)', 'E158:')
call assert_fails('call sign_getplaced("Xsign", [])', 'E715:')
call assert_equal([{'bufnr' : bufnr(''), 'signs' : []}],
***************
*** 451,457 ****
call assert_fails("call sign_unplace('',
\ {'id' : 20, 'buffer' : 'buffer.c'})", 'E158:')
call assert_fails("call sign_unplace('',
! \ {'id' : 20, 'buffer' : ''})", 'E158:')
call assert_fails("call sign_unplace('g1',
\ {'id' : 20, 'buffer' : 200})", 'E158:')
call assert_fails("call sign_unplace('g1', 'mySign')", 'E715:')
--- 451,457 ----
call assert_fails("call sign_unplace('',
\ {'id' : 20, 'buffer' : 'buffer.c'})", 'E158:')
call assert_fails("call sign_unplace('',
! \ {'id' : 20, 'buffer' : '&'})", 'E158:')
call assert_fails("call sign_unplace('g1',
\ {'id' : 20, 'buffer' : 200})", 'E158:')
call assert_fails("call sign_unplace('g1', 'mySign')", 'E715:')
***************
*** 1186,1188 ****
--- 1186,1247 ----
enew | only
call delete("Xsign")
endfunc
+
+ " Test for auto-adjusting the line number of a placed sign.
+ func Test_sign_lnum_adjust()
+ enew! | only!
+
+ sign define sign1 text=#> linehl=Comment
+ call setline(1, ['A', 'B', 'C', 'D'])
+ exe 'sign place 5 line=3 name=sign1 buffer=' . bufnr('')
+ let l = sign_getplaced(bufnr(''))
+ call assert_equal(3, l[0].signs[0].lnum)
+
+ " Add some lines before the sign and check the sign line number
+ call append(2, ['AA', 'AB', 'AC'])
+ let l = sign_getplaced(bufnr(''))
+ call assert_equal(6, l[0].signs[0].lnum)
+
+ " Delete some lines before the sign and check the sign line number
+ call deletebufline('%', 1, 2)
+ let l = sign_getplaced(bufnr(''))
+ call assert_equal(4, l[0].signs[0].lnum)
+
+ sign unplace * group=*
+ sign undefine sign1
+ enew!
+ endfunc
+
+ " Test for changing the type of a placed sign
+ func Test_sign_change_type()
+ enew! | only!
+
+ sign define sign1 text=#> linehl=Comment
+ sign define sign2 text=@@ linehl=Comment
+
+ call setline(1, ['A', 'B', 'C', 'D'])
+ exe 'sign place 4 line=3 name=sign1 buffer=' . bufnr('')
+ let l = sign_getplaced(bufnr(''))
+ call assert_equal('sign1', l[0].signs[0].name)
+ exe 'sign place 4 name=sign2 buffer=' . bufnr('')
+ let l = sign_getplaced(bufnr(''))
+ call assert_equal('sign2', l[0].signs[0].name)
+ call sign_place(4, '', 'sign1', '')
+ let l = sign_getplaced(bufnr(''))
+ call assert_equal('sign1', l[0].signs[0].name)
+
+ exe 'sign place 4 group=g1 line=4 name=sign1 buffer=' . bufnr('')
+ let l = sign_getplaced(bufnr(''), {'group' : 'g1'})
+ call assert_equal('sign1', l[0].signs[0].name)
+ exe 'sign place 4 group=g1 name=sign2 buffer=' . bufnr('')
+ let l = sign_getplaced(bufnr(''), {'group' : 'g1'})
+ call assert_equal('sign2', l[0].signs[0].name)
+ call sign_place(4, 'g1', 'sign1', '')
+ let l = sign_getplaced(bufnr(''), {'group' : 'g1'})
+ call assert_equal('sign1', l[0].signs[0].name)
+
+ sign unplace * group=*
+ sign undefine sign1
+ sign undefine sign2
+ enew!
+ endfunc
*** ../vim-8.1.0678/src/version.c 2019-01-02 00:02:07.607556145 +0100
--- src/version.c 2019-01-02 13:39:21.357897656 +0100
***************
*** 801,802 ****
--- 801,804 ----
{ /* Add new patch number below this line */
+ /**/
+ 679,
/**/
--
A fool learns from his mistakes, a wise man from someone else's.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|