]> granicus.if.org Git - vim/commitdiff
patch 8.1.0138: negative value of 'softtabstop' not used correctly v8.1.0138
authorBram Moolenaar <Bram@vim.org>
Mon, 2 Jul 2018 18:51:24 +0000 (20:51 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 2 Jul 2018 18:51:24 +0000 (20:51 +0200)
Problem:    Negative value of 'softtabstop' not used correctly.
Solution:   Use get_sts_value(). (Tom Ryder)

src/Makefile
src/edit.c
src/option.c
src/testdir/test_tab.vim
src/version.c

index ad9045104c30411c2fb4997df8766d340fa05e5e..86dae884a25f952257cc0e5a2dddf95349ed41fa 100644 (file)
@@ -2288,6 +2288,7 @@ test_arglist \
        test_syn_attr \
        test_syntax \
        test_system \
+       test_tab \
        test_tabline \
        test_tabpage \
        test_tagcase \
index d4de825af19a8b58d0caa2519144acb76660b97e..0519a015edceaf26d957d746d573a56304821eb3 100644 (file)
@@ -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,
index 50d42ebf7da503798a57079b578d1e5fbd85deaa..504b92a71a4b066273ef8ba7a2cc593a4e72c4b7 100644 (file)
@@ -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)
index b847dbd9628497d0acfafbe188d84b083d7fd97a..3be30245b93fef429676e0bed5e12a5413fbe507 100644 (file)
@@ -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
index 9c79148d06a19f4fc9cfb3537235ee732192aacc..2e928782587e38017480db3a1b833a0036e77235 100644 (file)
@@ -789,6 +789,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    138,
 /**/
     137,
 /**/