Skip to content

Commit c8ce615

Browse files
committed
patch 7.4.2174
Problem: Adding duplicate flags to 'whichwrap' leaves commas behind. Solution: Also remove the commas. (Naruhiko Nishino)
1 parent 3321e9d commit c8ce615

8 files changed

Lines changed: 66 additions & 32 deletions

File tree

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,6 @@ test1 \
20312031
test_mapping \
20322032
test_marks \
20332033
test_nested_function \
2034-
test_options \
20352034
test_search_mbyte \
20362035
test_signs \
20372036
test_tagcase \
@@ -2101,6 +2100,7 @@ test_arglist \
21012100
test_menu \
21022101
test_messages \
21032102
test_netbeans \
2103+
test_options \
21042104
test_packadd \
21052105
test_partial \
21062106
test_perl \

src/option.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4919,12 +4919,30 @@ do_set(
49194919
{
49204920
/* Remove flags that appear twice. */
49214921
for (s = newval; *s; ++s)
4922-
if ((!(flags & P_COMMA) || *s != ',')
4923-
&& vim_strchr(s + 1, *s) != NULL)
4922+
{
4923+
/* if options have P_FLAGLIST and
4924+
* P_ONECOMMA such as 'whichwrap' */
4925+
if (flags & P_ONECOMMA)
4926+
{
4927+
if (*s != ',' && *(s + 1) == ','
4928+
&& vim_strchr(s + 2, *s) != NULL)
4929+
{
4930+
/* Remove the duplicated value and
4931+
* the next comma. */
4932+
STRMOVE(s, s + 2);
4933+
s -= 2;
4934+
}
4935+
}
4936+
else
49244937
{
4925-
STRMOVE(s, s + 1);
4926-
--s;
4938+
if ((!(flags & P_COMMA) || *s != ',')
4939+
&& vim_strchr(s + 1, *s) != NULL)
4940+
{
4941+
STRMOVE(s, s + 1);
4942+
--s;
4943+
}
49274944
}
4945+
}
49284946
}
49294947

49304948
if (save_arg != NULL) /* number for 'whichwrap' */

src/testdir/Make_all.mak

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ SCRIPTS_ALL = \
101101
test_mapping.out \
102102
test_marks.out \
103103
test_nested_function.out \
104-
test_options.out \
105104
test_search_mbyte.out \
106105
test_signs.out \
107106
test_tagcase.out \

src/testdir/test_alot.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ source test_timers.vim
3838
source test_true_false.vim
3939
source test_unlet.vim
4040
source test_window_cmd.vim
41+
source test_options.vim

src/testdir/test_options.in

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/testdir/test_options.ok

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/testdir/test_options.vim

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
" Test for options
2+
3+
function! Test_whichwrap()
4+
set whichwrap=b,s
5+
call assert_equal('b,s', &whichwrap)
6+
7+
set whichwrap+=h,l
8+
call assert_equal('b,s,h,l', &whichwrap)
9+
10+
set whichwrap+=h,l
11+
call assert_equal('b,s,h,l', &whichwrap)
12+
13+
set whichwrap+=h,l
14+
call assert_equal('b,s,h,l', &whichwrap)
15+
16+
set whichwrap&
17+
endfunction
18+
19+
function! Test_options()
20+
let caught = 'ok'
21+
try
22+
options
23+
catch
24+
let caught = v:throwpoint . "\n" . v:exception
25+
endtry
26+
call assert_equal('ok', caught)
27+
28+
" close option-window
29+
close
30+
endfunction
31+
32+
function! Test_path_keep_commas()
33+
" Test that changing 'path' keeps two commas.
34+
set path=foo,,bar
35+
set path-=bar
36+
set path+=bar
37+
call assert_equal('foo,,bar', &path)
38+
39+
set path&
40+
endfunction

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ static char *(features[]) =
763763

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2174,
766768
/**/
767769
2173,
768770
/**/

0 commit comments

Comments
 (0)