diff options
author | James McCoy <jamessan@jamessan.com> | 2016-05-10 21:24:15 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2016-05-20 21:43:15 -0400 |
commit | 8a379aacd758056a89dfbd5e1a4d702ec57e9138 (patch) | |
tree | 6621a5bfd2bf474188fe9dee4f84ea884232228e | |
parent | 9d3449852bd35c9283948186d0259c1bf73b8579 (diff) | |
download | rneovim-8a379aacd758056a89dfbd5e1a4d702ec57e9138.tar.gz rneovim-8a379aacd758056a89dfbd5e1a4d702ec57e9138.tar.bz2 rneovim-8a379aacd758056a89dfbd5e1a4d702ec57e9138.zip |
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.
https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
-rw-r--r-- | src/nvim/option.c | 19 | ||||
-rw-r--r-- | src/nvim/version.c | 2 | ||||
-rw-r--r-- | test/functional/legacy/set_spec.lua | 15 |
3 files changed, 27 insertions, 9 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 2f22c245dd..45ebb4fa4c 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1639,18 +1639,21 @@ do_set ( && STRNCMP(s, newval, i) == 0 && (!(flags & P_COMMA) || s[i] == ',' - || s[i] == NUL)) + || s[i] == NUL)) { break; - /* Count backslashes. Only a comma with an - * even number of backslashes before it is - * recognized as a separator */ - if (s > origval && s[-1] == '\\') - ++bs; - else + } + // Count backslashes. Only a comma with an even number of + // backslashes or a single backslash preceded by a comma + // before it is recognized as a separator + if ((s > origval + 1 && s[-1] == '\\' && s[-2] != ',') + || (s == origval + 1 && s[-1] == '\\')) { + bs++; + } else { bs = 0; + } } - /* do not add if already there */ + // do not add if already there if ((adding || prepending) && *s) { prepending = FALSE; adding = FALSE; diff --git a/src/nvim/version.c b/src/nvim/version.c index 82a15f9833..b6b55964f3 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -667,7 +667,7 @@ static int included_patches[] = { // 1020 NA // 1019 NA // 1018, - // 1017, + 1017, // 1016 NA 1015, // 1014 NA diff --git a/test/functional/legacy/set_spec.lua b/test/functional/legacy/set_spec.lua index f81fcd3700..f2c907084e 100644 --- a/test/functional/legacy/set_spec.lua +++ b/test/functional/legacy/set_spec.lua @@ -7,6 +7,21 @@ local clear, execute, eval, eq = describe(':set', function() 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() execute('set wildignore=*.png,') execute('set wildignore+=*.jpg') |