changeset 31491:6d42026ad002 v9.0.1078

patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts' Commit: https://github.com/vim/vim/commit/07146ad1d33ba0d36b324873e5c461931e6b025e Author: zeertzjq <zeertzjq@outlook.com> Date: Mon Dec 19 15:51:44 2022 +0000 patch 9.0.1078: with the +vartabs feature indent folding may use wrong 'ts' Problem: With the +vartabs feature indent folding may use wrong 'tabstop'. Solution: Use the "buf" argument instead of "curbuf".
author Bram Moolenaar <Bram@vim.org>
date Mon, 19 Dec 2022 17:00:05 +0100
parents 97e0789e6d10
children 6b30ccb7cbe9
files src/indent.c src/testdir/test_fold.vim src/version.c
diffstat 3 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/indent.c
+++ b/src/indent.c
@@ -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
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -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']
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1078,
+/**/
     1077,
 /**/
     1076,