vim-patch:7.4.741 #4121

Problem:    When using += with ":set" a trailing comma is not recognized.
            (Issue 365)
Solution:   Don't add a second comma. Add a test. (partly by Christian
            Brabandt)

a7b7b1cef9
This commit is contained in:
Jurica Bradaric
2016-01-28 19:28:15 +01:00
committed by Justin M. Keyes
parent 99067b7e56
commit 59ef994f8f
3 changed files with 21 additions and 1 deletions

View File

@@ -1673,6 +1673,11 @@ do_set (
&& *newval != NUL); && *newval != NUL);
if (adding) { if (adding) {
i = (int)STRLEN(origval); i = (int)STRLEN(origval);
// Strip a trailing comma, would get 2.
if (comma && i > 1 && origval[i - 1] == ','
&& origval[i - 2] != '\\') {
--i;
}
memmove(newval + i + comma, newval, memmove(newval + i + comma, newval,
STRLEN(newval) + 1); STRLEN(newval) + 1);
memmove(newval, origval, (size_t)i); memmove(newval, origval, (size_t)i);

View File

@@ -421,7 +421,7 @@ static int included_patches[] = {
// 744 NA // 744 NA
// 743, // 743,
// 742, // 742,
// 741, 741,
// 740, // 740,
739, 739,
// 738 NA // 738 NA

View File

@@ -0,0 +1,15 @@
-- Tests for :set
local helpers = require('test.functional.helpers')
local clear, execute, eval, eq =
helpers.clear, helpers.execute, helpers.eval, helpers.eq
describe(':set', function()
before_each(clear)
it('recognizes a trailing comma with +=', function()
execute('set wildignore=*.png,')
execute('set wildignore+=*.jpg')
eq('*.png,*.jpg', eval('&wildignore'))
end)
end)