vim-patch:7.4.1017

Problem:    When there is a backslash in an option ":set -=" doesn't work.
Solution:   Handle a backslash better. (Jacob Niehus)  Add a new test, merge
            in old test.

8f79acdf7e
This commit is contained in:
James McCoy
2016-05-10 21:24:15 -04:00
parent 9d3449852b
commit 8a379aacd7
3 changed files with 27 additions and 9 deletions

View File

@@ -1639,18 +1639,21 @@ do_set (
&& STRNCMP(s, newval, i) == 0 && STRNCMP(s, newval, i) == 0
&& (!(flags & P_COMMA) && (!(flags & P_COMMA)
|| s[i] == ',' || s[i] == ','
|| s[i] == NUL)) || s[i] == NUL)) {
break; break;
/* Count backslashes. Only a comma with an }
* even number of backslashes before it is // Count backslashes. Only a comma with an even number of
* recognized as a separator */ // backslashes or a single backslash preceded by a comma
if (s > origval && s[-1] == '\\') // before it is recognized as a separator
++bs; if ((s > origval + 1 && s[-1] == '\\' && s[-2] != ',')
else || (s == origval + 1 && s[-1] == '\\')) {
bs++;
} else {
bs = 0; bs = 0;
}
} }
/* do not add if already there */ // do not add if already there
if ((adding || prepending) && *s) { if ((adding || prepending) && *s) {
prepending = FALSE; prepending = FALSE;
adding = FALSE; adding = FALSE;

View File

@@ -667,7 +667,7 @@ static int included_patches[] = {
// 1020 NA // 1020 NA
// 1019 NA // 1019 NA
// 1018, // 1018,
// 1017, 1017,
// 1016 NA // 1016 NA
1015, 1015,
// 1014 NA // 1014 NA

View File

@@ -7,6 +7,21 @@ local clear, execute, eval, eq =
describe(':set', function() describe(':set', function()
before_each(clear) before_each(clear)
it('handles backslash properly', function()
execute('set iskeyword=a,b,c')
execute('set iskeyword+=d')
eq('a,b,c,d', eval('&iskeyword'))
execute([[set iskeyword+=\\,e]])
eq([[a,b,c,d,\,e]], eval('&iskeyword'))
execute('set iskeyword-=e')
eq([[a,b,c,d,\]], eval('&iskeyword'))
execute([[set iskeyword-=\]])
eq('a,b,c,d', eval('&iskeyword'))
end)
it('recognizes a trailing comma with +=', function() it('recognizes a trailing comma with +=', function()
execute('set wildignore=*.png,') execute('set wildignore=*.png,')
execute('set wildignore+=*.jpg') execute('set wildignore+=*.jpg')