]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts' v9.0.1078
authorzeertzjq <zeertzjq@outlook.com>
Mon, 19 Dec 2022 15:51:44 +0000 (15:51 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 19 Dec 2022 15:51:44 +0000 (15:51 +0000)
Problem:    With the +vartabs feature indent folding may use wrong 'tabstop'.
Solution:   Use the "buf" argument instead of "curbuf".

src/indent.c
src/testdir/test_fold.vim
src/version.c

index aaf3caafc4d63a1ea23e11350d61bd9b851199a6..cbb3f94f4b1439224f86aae2d8dddc5c48745019 100644 (file)
@@ -420,7 +420,7 @@ get_indent_buf(buf_T *buf, linenr_T lnum)
 {
 # ifdef FEAT_VARTABS
     return get_indent_str_vtab(ml_get_buf(buf, lnum, FALSE),
-                              (int)curbuf->b_p_ts, buf->b_p_vts_array, FALSE);
+                              (int)buf->b_p_ts, buf->b_p_vts_array, FALSE);
 # else
     return get_indent_str(ml_get_buf(buf, lnum, FALSE), (int)buf->b_p_ts, FALSE);
 # endif
index 2f4aade0133cd61c5c62cf5e4218c55e39cde75b..adf9e52078383a801d8a72980eb9f4ba2d324fd3 100644 (file)
@@ -157,6 +157,27 @@ func Test_indent_fold_max()
   bw!
 endfunc
 
+func Test_indent_fold_tabstop()
+  call setline(1, ['0', '    1', '    1', "\t2", "\t2"])
+  setlocal shiftwidth=4
+  setlocal foldcolumn=1
+  setlocal foldlevel=2
+  setlocal foldmethod=indent
+  redraw
+  call assert_equal('2        2', ScreenLines(5, 10)[0])
+  vsplit
+  windo diffthis
+  botright new
+  " This 'tabstop' value should not be used for folding in other buffers.
+  setlocal tabstop=4
+  diffoff!
+  redraw
+  call assert_equal('2        2', ScreenLines(5, 10)[0])
+
+  bwipe!
+  bwipe!
+endfunc
+
 func Test_manual_fold_with_filter()
   CheckExecutable cat
   for type in ['manual', 'marker']
index a2b4e7ecbb6843906e981a82dae6cf602762ea34..1ce40429597ffdc2de4c4da4d705e947f1d392d9 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1078,
 /**/
     1077,
 /**/