summaryrefslogtreecommitdiffstats
path: root/src/testdir
diff options
context:
space:
mode:
authorShota Nozaki <emonkak@gmail.com>2024-01-03 19:18:43 +0100
committerChristian Brabandt <cb@256bit.org>2024-01-03 19:18:43 +0100
commit0689b870595c687a23e102913ce5037f65d03748 (patch)
tree168af75375f949bf0f26943894fe974349ea6e56 /src/testdir
parentbf44b69d1f91d9778ae1887128c63d35d9a3d19b (diff)
patch 9.1.0002: a closing fold expr, may start a new foldv9.1.0002
Problem: a closing fold expression may unexpectedly start a new fold when it should end a fold (reported by Shota Nozaki) Solution: if a fold hasn't started yet, do not immediately start a new fold with level 1 (Shota Nozaki) fixes: #12768 closes: #13748 Signed-off-by: Shota Nozaki <emonkak@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/test_fold.vim13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim
index cb29d43d54..3c78e62c3e 100644
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -1778,4 +1778,17 @@ func Test_foldexpr_return_empty_string()
bwipe!
endfunc
+" Make sure that when ending a fold that hasn't been started, it does not
+" start a new fold.
+func Test_foldexpr_end_fold()
+ new
+ setlocal foldmethod=expr
+ let &l:foldexpr = 'v:lnum == 2 ? "<2" : "="'
+ call setline(1, range(1, 3))
+ redraw
+ call assert_equal([0, 0, 0], range(1, 3)->map('foldlevel(v:val)'))
+
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab