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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0939
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.0939
Problem: No completion for sign group names.
Solution: Add completion for sign group names and buffer names. (Yegappan
Lakshmanan, closes #3980)
Files: src/sign.c, src/testdir/test_signs.vim
*** ../vim-8.1.0938/src/sign.c 2019-01-24 17:18:37.591462362 +0100
--- src/sign.c 2019-02-17 14:45:25.699785487 +0100
***************
*** 1767,1786 ****
EXP_SUBCMD, // expand :sign sub-commands
EXP_DEFINE, // expand :sign define {name} args
EXP_PLACE, // expand :sign place {id} args
EXP_UNPLACE, // expand :sign unplace"
! EXP_SIGN_NAMES // expand with name of placed signs
} expand_what;
/*
* Function given to ExpandGeneric() to obtain the sign command
* expansion.
*/
char_u *
get_sign_name(expand_T *xp UNUSED, int idx)
{
- sign_T *sp;
- int current_idx;
-
switch (expand_what)
{
case EXP_SUBCMD:
--- 1767,1831 ----
EXP_SUBCMD, // expand :sign sub-commands
EXP_DEFINE, // expand :sign define {name} args
EXP_PLACE, // expand :sign place {id} args
+ EXP_LIST, // expand :sign place args
EXP_UNPLACE, // expand :sign unplace"
! EXP_SIGN_NAMES, // expand with name of placed signs
! EXP_SIGN_GROUPS // expand with name of placed sign groups
} expand_what;
/*
+ * Return the n'th sign name (used for command line completion)
+ */
+ static char_u *
+ get_nth_sign_name(int idx)
+ {
+ int current_idx;
+ sign_T *sp;
+
+ // Complete with name of signs already defined
+ current_idx = 0;
+ for (sp = first_sign; sp != NULL; sp = sp->sn_next)
+ if (current_idx++ == idx)
+ return sp->sn_name;
+ return NULL;
+ }
+
+ /*
+ * Return the n'th sign group name (used for command line completion)
+ */
+ static char_u *
+ get_nth_sign_group_name(int idx)
+ {
+ int current_idx;
+ int todo;
+ hashitem_T *hi;
+ signgroup_T *group;
+
+ // Complete with name of sign groups already defined
+ current_idx = 0;
+ todo = (int)sg_table.ht_used;
+ for (hi = sg_table.ht_array; todo > 0; ++hi)
+ {
+ if (!HASHITEM_EMPTY(hi))
+ {
+ --todo;
+ if (current_idx++ == idx)
+ {
+ group = HI2SG(hi);
+ return group->sg_name;
+ }
+ }
+ }
+ return NULL;
+ }
+
+ /*
* Function given to ExpandGeneric() to obtain the sign command
* expansion.
*/
char_u *
get_sign_name(expand_T *xp UNUSED, int idx)
{
switch (expand_what)
{
case EXP_SUBCMD:
***************
*** 1802,1819 ****
};
return (char_u *)place_arg[idx];
}
case EXP_UNPLACE:
{
char *unplace_arg[] = { "group=", "file=", "buffer=", NULL };
return (char_u *)unplace_arg[idx];
}
case EXP_SIGN_NAMES:
! // Complete with name of signs already defined
! current_idx = 0;
! for (sp = first_sign; sp != NULL; sp = sp->sn_next)
! if (current_idx++ == idx)
! return sp->sn_name;
! return NULL;
default:
return NULL;
}
--- 1847,1869 ----
};
return (char_u *)place_arg[idx];
}
+ case EXP_LIST:
+ {
+ char *list_arg[] =
+ {
+ "group=", "file=", "buffer=", NULL
+ };
+ return (char_u *)list_arg[idx];
+ }
case EXP_UNPLACE:
{
char *unplace_arg[] = { "group=", "file=", "buffer=", NULL };
return (char_u *)unplace_arg[idx];
}
case EXP_SIGN_NAMES:
! return get_nth_sign_name(idx);
! case EXP_SIGN_GROUPS:
! return get_nth_sign_group_name(idx);
default:
return NULL;
}
***************
*** 1848,1875 ****
// |
// begin_subcmd_args
begin_subcmd_args = skipwhite(end_subcmd);
- p = skiptowhite(begin_subcmd_args);
- if (*p == NUL)
- {
- //
- // Expand first argument of subcmd when possible.
- // For ":jump {id}" and ":unplace {id}", we could
- // possibly expand the ids of all signs already placed.
- //
- xp->xp_pattern = begin_subcmd_args;
- switch (cmd_idx)
- {
- case SIGNCMD_LIST:
- case SIGNCMD_UNDEFINE:
- // :sign list <CTRL-D>
- // :sign undefine <CTRL-D>
- expand_what = EXP_SIGN_NAMES;
- break;
- default:
- xp->xp_context = EXPAND_NOTHING;
- }
- return;
- }
// expand last argument of subcmd
--- 1898,1903 ----
***************
*** 1878,1883 ****
--- 1906,1912 ----
// p
// Loop until reaching last argument.
+ p = begin_subcmd_args;
do
{
p = skipwhite(p);
***************
*** 1900,1906 ****
expand_what = EXP_DEFINE;
break;
case SIGNCMD_PLACE:
! expand_what = EXP_PLACE;
break;
case SIGNCMD_JUMP:
case SIGNCMD_UNPLACE:
--- 1929,1947 ----
expand_what = EXP_DEFINE;
break;
case SIGNCMD_PLACE:
! // List placed signs
! if (VIM_ISDIGIT(*begin_subcmd_args))
! // :sign place {id} {args}...
! expand_what = EXP_PLACE;
! else
! // :sign place {args}...
! expand_what = EXP_LIST;
! break;
! case SIGNCMD_LIST:
! case SIGNCMD_UNDEFINE:
! // :sign list <CTRL-D>
! // :sign undefine <CTRL-D>
! expand_what = EXP_SIGN_NAMES;
break;
case SIGNCMD_JUMP:
case SIGNCMD_UNPLACE:
***************
*** 1917,1933 ****
switch (cmd_idx)
{
case SIGNCMD_DEFINE:
! if (STRNCMP(last, "texthl", p - last) == 0
! || STRNCMP(last, "linehl", p - last) == 0)
xp->xp_context = EXPAND_HIGHLIGHT;
! else if (STRNCMP(last, "icon", p - last) == 0)
xp->xp_context = EXPAND_FILES;
else
xp->xp_context = EXPAND_NOTHING;
break;
case SIGNCMD_PLACE:
! if (STRNCMP(last, "name", p - last) == 0)
expand_what = EXP_SIGN_NAMES;
else
xp->xp_context = EXPAND_NOTHING;
break;
--- 1958,1987 ----
switch (cmd_idx)
{
case SIGNCMD_DEFINE:
! if (STRNCMP(last, "texthl", 6) == 0
! || STRNCMP(last, "linehl", 6) == 0)
xp->xp_context = EXPAND_HIGHLIGHT;
! else if (STRNCMP(last, "icon", 4) == 0)
xp->xp_context = EXPAND_FILES;
else
xp->xp_context = EXPAND_NOTHING;
break;
case SIGNCMD_PLACE:
! if (STRNCMP(last, "name", 4) == 0)
expand_what = EXP_SIGN_NAMES;
+ else if (STRNCMP(last, "group", 5) == 0)
+ expand_what = EXP_SIGN_GROUPS;
+ else if (STRNCMP(last, "file", 4) == 0)
+ xp->xp_context = EXPAND_BUFFERS;
+ else
+ xp->xp_context = EXPAND_NOTHING;
+ break;
+ case SIGNCMD_UNPLACE:
+ case SIGNCMD_JUMP:
+ if (STRNCMP(last, "group", 5) == 0)
+ expand_what = EXP_SIGN_GROUPS;
+ else if (STRNCMP(last, "file", 4) == 0)
+ xp->xp_context = EXPAND_BUFFERS;
else
xp->xp_context = EXPAND_NOTHING;
break;
*** ../vim-8.1.0938/src/testdir/test_signs.vim 2019-01-17 17:36:42.495509219 +0100
--- src/testdir/test_signs.vim 2019-02-17 14:45:25.699785487 +0100
***************
*** 210,222 ****
call assert_equal('"sign define Sign linehl=SpellBad SpellCap ' .
\ 'SpellLocal SpellRare', @:)
! call writefile(['foo'], 'XsignOne')
! call writefile(['bar'], 'XsignTwo')
call feedkeys(":sign define Sign icon=Xsig\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign define Sign icon=XsignOne XsignTwo', @:)
- call delete('XsignOne')
- call delete('XsignTwo')
call feedkeys(":sign undefine \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign undefine Sign1 Sign2', @:)
--- 210,225 ----
call assert_equal('"sign define Sign linehl=SpellBad SpellCap ' .
\ 'SpellLocal SpellRare', @:)
! call feedkeys(":sign define Sign texthl=Spell\<C-A>\<C-B>\"\<CR>", 'tx')
! call assert_equal('"sign define Sign texthl=SpellBad SpellCap ' .
! \ 'SpellLocal SpellRare', @:)
!
! call writefile(repeat(["Sun is shining"], 30), "XsignOne")
! call writefile(repeat(["Sky is blue"], 30), "XsignTwo")
call feedkeys(":sign define Sign icon=Xsig\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign define Sign icon=XsignOne XsignTwo', @:)
+ " Test for completion of arguments to ':sign undefine'
call feedkeys(":sign undefine \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign undefine Sign1 Sign2', @:)
***************
*** 227,243 ****
--- 230,299 ----
call feedkeys(":sign place 1 name=\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign place 1 name=Sign1 Sign2', @:)
+ edit XsignOne
+ sign place 1 name=Sign1 line=5
+ sign place 1 name=Sign1 group=g1 line=10
+ edit XsignTwo
+ sign place 1 name=Sign2 group=g2 line=15
+
+ " Test for completion of group= and file= arguments to ':sign place'
+ call feedkeys(":sign place 1 name=Sign1 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place 1 name=Sign1 file=XsignOne XsignTwo', @:)
+ call feedkeys(":sign place 1 name=Sign1 group=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place 1 name=Sign1 group=g1 g2', @:)
+
+ " Test for completion of arguments to 'sign place' without sign identifier
+ call feedkeys(":sign place \<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place buffer= file= group=', @:)
+ call feedkeys(":sign place file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place file=XsignOne XsignTwo', @:)
+ call feedkeys(":sign place group=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place group=g1 g2', @:)
+ call feedkeys(":sign place group=g1 file=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign place group=g1 file=XsignOne XsignTwo', @:)
+
+ " Test for completion of arguments to ':sign unplace'
call feedkeys(":sign unplace 1 \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign unplace 1 buffer= file= group=', @:)
+ call feedkeys(":sign unplace 1 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign unplace 1 file=XsignOne XsignTwo', @:)
+ call feedkeys(":sign unplace 1 group=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign unplace 1 group=g1 g2', @:)
+ call feedkeys(":sign unplace 1 group=g2 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign unplace 1 group=g2 file=XsignOne XsignTwo', @:)
+ " Test for completion of arguments to ':sign list'
call feedkeys(":sign list \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign list Sign1 Sign2', @:)
+ " Test for completion of arguments to ':sign jump'
call feedkeys(":sign jump 1 \<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"sign jump 1 buffer= file= group=', @:)
+ call feedkeys(":sign jump 1 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign jump 1 file=XsignOne XsignTwo', @:)
+ call feedkeys(":sign jump 1 group=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign jump 1 group=g1 g2', @:)
+
+ " Error cases
+ call feedkeys(":sign here\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal('"sign here', @:)
+ call feedkeys(":sign define Sign here=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal("\"sign define Sign here=\<C-A>", @:)
+ call feedkeys(":sign place 1 here=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal("\"sign place 1 here=\<C-A>", @:)
+ call feedkeys(":sign jump 1 here=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal("\"sign jump 1 here=\<C-A>", @:)
+ call feedkeys(":sign here there\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal("\"sign here there\<C-A>", @:)
+ call feedkeys(":sign here there=\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_equal("\"sign here there=\<C-A>", @:)
+ sign unplace * group=*
sign undefine Sign1
sign undefine Sign2
+ enew
+ call delete('XsignOne')
+ call delete('XsignTwo')
endfunc
func Test_sign_invalid_commands()
*** ../vim-8.1.0938/src/version.c 2019-02-17 14:10:52.105754303 +0100
--- src/version.c 2019-02-17 14:46:51.643306843 +0100
***************
*** 781,782 ****
--- 781,784 ----
{ /* Add new patch number below this line */
+ /**/
+ 939,
/**/
--
Scientists decoded the first message from an alien civilization:
SIMPLY SEND 6 TIMES 10 TO THE 50 ATOMS OF HYDROGEN TO THE STAR
SYSTEM AT THE TOP OF THE LIST, CROSS OFF THAT STAR SYSTEM, THEN PUT
YOUR STAR SYSTEM AT THE BOTTOM OF THE LIST AND SEND IT TO 100 OTHER
STAR SYSTEMS. WITHIN ONE TENTH GALACTIC ROTATION YOU WILL RECEIVE
ENOUGH HYDROGREN TO POWER YOUR CIVILIZATION UNTIL ENTROPY REACHES ITS
MAXIMUM! IT REALLY WORKS!
/// 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 ///
|