Skip to content

Commit 33d5ab3

Browse files
committed
patch 8.1.0138: negative value of 'softtabstop' not used correctly
Problem: Negative value of 'softtabstop' not used correctly. Solution: Use get_sts_value(). (Tom Ryder)
1 parent ade5578 commit 33d5ab3

5 files changed

Lines changed: 43 additions & 4 deletions

File tree

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,7 @@ test_arglist \
22882288
test_syn_attr \
22892289
test_syntax \
22902290
test_system \
2291+
test_tab \
22912292
test_tabline \
22922293
test_tabpage \
22932294
test_tagcase \

src/edit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9373,7 +9373,7 @@ ins_bs(
93739373
if (p_sta && in_indent)
93749374
want_vcol = (want_vcol / curbuf->b_p_sw) * curbuf->b_p_sw;
93759375
else
9376-
want_vcol = tabstop_start(want_vcol, curbuf->b_p_sts,
9376+
want_vcol = tabstop_start(want_vcol, get_sts_value(),
93779377
curbuf->b_p_vsts_array);
93789378
#else
93799379
want_vcol = (want_vcol / ts) * ts;
@@ -10203,9 +10203,9 @@ ins_tab(void)
1020310203
temp = (int)curbuf->b_p_sw;
1020410204
temp -= get_nolist_virtcol() % temp;
1020510205
}
10206-
else if (tabstop_count(curbuf->b_p_vsts_array) > 0 || curbuf->b_p_sts > 0)
10206+
else if (tabstop_count(curbuf->b_p_vsts_array) > 0 || curbuf->b_p_sts != 0)
1020710207
/* use 'softtabstop' when set */
10208-
temp = tabstop_padding(get_nolist_virtcol(), curbuf->b_p_sts,
10208+
temp = tabstop_padding(get_nolist_virtcol(), get_sts_value(),
1020910209
curbuf->b_p_vsts_array);
1021010210
else /* otherwise use 'tabstop' */
1021110211
temp = tabstop_padding(get_nolist_virtcol(), curbuf->b_p_ts,

src/option.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13016,7 +13016,7 @@ get_sw_value(buf_T *buf)
1301613016

1301713017
/*
1301813018
* Return the effective softtabstop value for the current buffer, using the
13019-
* 'tabstop' value when 'softtabstop' is negative.
13019+
* 'shiftwidth' value when 'softtabstop' is negative.
1302013020
*/
1302113021
long
1302213022
get_sts_value(void)

src/testdir/test_tab.vim

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
" Various tests for inserting a Tab.
12

23
" Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set.
34
" Also test that dv_ works correctly
@@ -43,3 +44,38 @@ func Test_smarttab()
4344
enew!
4445
set expandtab& smartindent& copyindent& ts& sw& sts&
4546
endfunc
47+
48+
func Test_softtabstop()
49+
new
50+
set sts=0 sw=0
51+
exe "normal ix\<Tab>x\<Esc>"
52+
call assert_equal("x\tx", getline(1))
53+
54+
call setline(1, '')
55+
set sts=4
56+
exe "normal ix\<Tab>x\<Esc>"
57+
call assert_equal("x x", getline(1))
58+
59+
call setline(1, '')
60+
set sts=-1 sw=4
61+
exe "normal ix\<Tab>x\<Esc>"
62+
call assert_equal("x x", getline(1))
63+
64+
call setline(1, 'x ')
65+
set sts=0 sw=0 backspace=start
66+
exe "normal A\<BS>x\<Esc>"
67+
call assert_equal("x x", getline(1))
68+
69+
call setline(1, 'x ')
70+
set sts=4
71+
exe "normal A\<BS>x\<Esc>"
72+
call assert_equal("x x", getline(1))
73+
74+
call setline(1, 'x ')
75+
set sts=-1 sw=4
76+
exe "normal A\<BS>x\<Esc>"
77+
call assert_equal("x x", getline(1))
78+
79+
set sts=0 sw=0 backspace&
80+
bwipe!
81+
endfunc

src/version.c

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

790790
static int included_patches[] =
791791
{ /* Add new patch number below this line */
792+
/**/
793+
138,
792794
/**/
793795
137,
794796
/**/

0 commit comments

Comments
 (0)