diff options
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r-- | src/nvim/option.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 3bd1ce217e..0f95974cb4 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1727,13 +1727,25 @@ do_set ( } if (flags & P_FLAGLIST) { - /* Remove flags that appear twice. */ - for (s = newval; *s; ++s) - if ((!(flags & P_COMMA) || *s != ',') - && vim_strchr(s + 1, *s) != NULL) { - STRMOVE(s, s + 1); - --s; + // Remove flags that appear twice. + for (s = newval; *s; s++) { + // if options have P_FLAGLIST and P_ONECOMMA such as + // 'whichwrap' + if (flags & P_ONECOMMA) { + if (*s != ',' && *(s + 1) == ',' + && vim_strchr(s + 2, *s) != NULL) { + // Remove the duplicated value and the next comma. + STRMOVE(s, s + 2); + s -= 2; + } + } else { + if ((!(flags & P_COMMA) || *s != ',') + && vim_strchr(s + 1, *s) != NULL) { + STRMOVE(s, s + 1); + s--; + } } + } } if (save_arg != NULL) /* number for 'whichwrap' */ |