diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-07-02 20:51:24 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-07-02 20:51:24 +0200 |
commit | 33d5ab3795720b7d986f9f17f660ee9e448466e0 (patch) | |
tree | 38af7f84382c74a45dc271d9f37eac9ac148dde4 /src | |
parent | ade55787978e15fe57c5cedf38c9f85bfe1d983c (diff) |
patch 8.1.0138: negative value of 'softtabstop' not used correctlyv8.1.0138
Problem: Negative value of 'softtabstop' not used correctly.
Solution: Use get_sts_value(). (Tom Ryder)
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 1 | ||||
-rw-r--r-- | src/edit.c | 6 | ||||
-rw-r--r-- | src/option.c | 2 | ||||
-rw-r--r-- | src/testdir/test_tab.vim | 36 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 43 insertions, 4 deletions
diff --git a/src/Makefile b/src/Makefile index ad9045104c..86dae884a2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2288,6 +2288,7 @@ test_arglist \ test_syn_attr \ test_syntax \ test_system \ + test_tab \ test_tabline \ test_tabpage \ test_tagcase \ diff --git a/src/edit.c b/src/edit.c index d4de825af1..0519a015ed 100644 --- a/src/edit.c +++ b/src/edit.c @@ -9373,7 +9373,7 @@ ins_bs( if (p_sta && in_indent) want_vcol = (want_vcol / curbuf->b_p_sw) * curbuf->b_p_sw; else - want_vcol = tabstop_start(want_vcol, curbuf->b_p_sts, + want_vcol = tabstop_start(want_vcol, get_sts_value(), curbuf->b_p_vsts_array); #else want_vcol = (want_vcol / ts) * ts; @@ -10203,9 +10203,9 @@ ins_tab(void) temp = (int)curbuf->b_p_sw; temp -= get_nolist_virtcol() % temp; } - else if (tabstop_count(curbuf->b_p_vsts_array) > 0 || curbuf->b_p_sts > 0) + else if (tabstop_count(curbuf->b_p_vsts_array) > 0 || curbuf->b_p_sts != 0) /* use 'softtabstop' when set */ - temp = tabstop_padding(get_nolist_virtcol(), curbuf->b_p_sts, + temp = tabstop_padding(get_nolist_virtcol(), get_sts_value(), curbuf->b_p_vsts_array); else /* otherwise use 'tabstop' */ temp = tabstop_padding(get_nolist_virtcol(), curbuf->b_p_ts, diff --git a/src/option.c b/src/option.c index 50d42ebf7d..504b92a71a 100644 --- a/src/option.c +++ b/src/option.c @@ -13016,7 +13016,7 @@ get_sw_value(buf_T *buf) /* * Return the effective softtabstop value for the current buffer, using the - * 'tabstop' value when 'softtabstop' is negative. + * 'shiftwidth' value when 'softtabstop' is negative. */ long get_sts_value(void) diff --git a/src/testdir/test_tab.vim b/src/testdir/test_tab.vim index b847dbd962..3be30245b9 100644 --- a/src/testdir/test_tab.vim +++ b/src/testdir/test_tab.vim @@ -1,3 +1,4 @@ +" Various tests for inserting a Tab. " Tests for "r<Tab>" with 'smarttab' and 'expandtab' set/not set. " Also test that dv_ works correctly @@ -43,3 +44,38 @@ func Test_smarttab() enew! set expandtab& smartindent& copyindent& ts& sw& sts& endfunc + +func Test_softtabstop() + new + set sts=0 sw=0 + exe "normal ix\<Tab>x\<Esc>" + call assert_equal("x\tx", getline(1)) + + call setline(1, '') + set sts=4 + exe "normal ix\<Tab>x\<Esc>" + call assert_equal("x x", getline(1)) + + call setline(1, '') + set sts=-1 sw=4 + exe "normal ix\<Tab>x\<Esc>" + call assert_equal("x x", getline(1)) + + call setline(1, 'x ') + set sts=0 sw=0 backspace=start + exe "normal A\<BS>x\<Esc>" + call assert_equal("x x", getline(1)) + + call setline(1, 'x ') + set sts=4 + exe "normal A\<BS>x\<Esc>" + call assert_equal("x x", getline(1)) + + call setline(1, 'x ') + set sts=-1 sw=4 + exe "normal A\<BS>x\<Esc>" + call assert_equal("x x", getline(1)) + + set sts=0 sw=0 backspace& + bwipe! +endfunc diff --git a/src/version.c b/src/version.c index 9c79148d06..2e92878258 100644 --- a/src/version.c +++ b/src/version.c @@ -790,6 +790,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 138, +/**/ 137, /**/ 136, |