]> granicus.if.org Git - vim/commitdiff
patch 8.1.0154: crash with "set smarttab shiftwidth=0 softtabstop=-1" v8.1.0154
authorBram Moolenaar <Bram@vim.org>
Thu, 5 Jul 2018 20:27:08 +0000 (22:27 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 5 Jul 2018 20:27:08 +0000 (22:27 +0200)
Problem:    Crash with "set smarttab shiftwidth=0 softtabstop=-1".
Solution:   Fall back to using 'tabstop'. (closes #3155)

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

index 0519a015edceaf26d957d746d573a56304821eb3..5f6ac19a06c8e03c92f216a2459f82d289922812 100644 (file)
@@ -9347,20 +9347,12 @@ ins_bs(
                                && (!*inserted_space_p
                                    || arrow_used))))))
        {
-#ifndef FEAT_VARTABS
            int         ts;
-#endif
            colnr_T     vcol;
            colnr_T     want_vcol;
            colnr_T     start_vcol;
 
            *inserted_space_p = FALSE;
-#ifndef FEAT_VARTABS
-           if (p_sta && in_indent)
-               ts = (int)get_sw_value(curbuf);
-           else
-               ts = (int)get_sts_value();
-#endif
            /* Compute the virtual column where we want to be.  Since
             * 'showbreak' may get in the way, need to get the last column of
             * the previous character. */
@@ -9371,11 +9363,18 @@ ins_bs(
            inc_cursor();
 #ifdef FEAT_VARTABS
            if (p_sta && in_indent)
-               want_vcol = (want_vcol / curbuf->b_p_sw) * curbuf->b_p_sw;
+           {
+               ts = (int)get_sw_value(curbuf);
+               want_vcol = (want_vcol / ts) * ts;
+           }
            else
                want_vcol = tabstop_start(want_vcol, get_sts_value(),
                                                     curbuf->b_p_vsts_array);
 #else
+           if (p_sta && in_indent)
+               ts = (int)get_sw_value(curbuf);
+           else
+               ts = (int)get_sts_value();
            want_vcol = (want_vcol / ts) * ts;
 #endif
 
@@ -10200,7 +10199,7 @@ ins_tab(void)
 #ifdef FEAT_VARTABS
     if (p_sta && ind)          /* insert tab in indent, use 'shiftwidth' */
     {
-       temp = (int)curbuf->b_p_sw;
+       temp = (int)get_sw_value(curbuf);
        temp -= get_nolist_virtcol() % temp;
     }
     else if (tabstop_count(curbuf->b_p_vsts_array) > 0 || curbuf->b_p_sts != 0)
index 3be30245b93fef429676e0bed5e12a5413fbe507..b8e8dfe0629a4bf0719c5cf07162d62aecbd9bca 100644 (file)
@@ -76,6 +76,15 @@ func Test_softtabstop()
   exe "normal A\<BS>x\<Esc>"
   call assert_equal("x   x", getline(1))
 
-  set sts=0 sw=0 backspace&
+  call setline(1, 'x')
+  set sts=-1 sw=0 smarttab
+  exe "normal I\<Tab>\<Esc>"
+  call assert_equal("\tx", getline(1))
+
+  call setline(1, 'x')
+  exe "normal I\<Tab>\<BS>\<Esc>"
+  call assert_equal("x", getline(1))
+
+  set sts=0 sw=0 backspace& nosmarttab
   bwipe!
 endfunc
index cfcbe53a32da11ce2c21c4ab0db798372d4ad26c..8d97843c554520bad16cc95dbd5d1378dc5fd5d2 100644 (file)
@@ -789,6 +789,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    154,
 /**/
     153,
 /**/