patch 8.2.4935: with 'foldmethod' "indent" some lines not included in fold
Problem: With 'foldmethod' "indent" some lines are not included in the
fold. (Oleg Koshovetc)
Solution: Fix it. (Brandon Simmons, closes #10399, closes #3214)
diff --git a/src/fold.c b/src/fold.c
index f94b389..7c51557 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -2246,7 +2246,14 @@
getlevel = foldlevelDiff;
#endif
else
+ {
getlevel = foldlevelIndent;
+ // Start one line back, because if the line above "top" has an
+ // undefined fold level, folding it relies on the line under it,
+ // which is "top".
+ if (top > 1)
+ --fline.lnum;
+ }
// Backup to a line for which the fold level is defined. Since it's
// always defined for line one, we will stop there.
diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim
index 3abb81a..52185dc 100644
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -1459,4 +1459,24 @@
bw!
endfunc
+" Make sure that when you append under a blank line that is under a fold with
+" the same indent level as your appended line, the fold expands across the
+" blank line
+func Test_indent_append_under_blank_line()
+ new
+ let lines =<< trim END
+ line 1
+ line 2
+ line 3
+ END
+ call setline(1, lines)
+ setlocal sw=2
+ setlocal foldmethod=indent foldenable
+ call assert_equal([0, 1, 1], range(1, 3)->map('foldlevel(v:val)'))
+ call append(3, '')
+ call append(4, ' line 5')
+ call assert_equal([0, 1, 1, 1, 1], range(1, 5)->map('foldlevel(v:val)'))
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 80f631b..2de3cb1 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4935,
+/**/
4934,
/**/
4933,