patch 8.2.4813: pasting text while indent folding may mess up folds
Problem: Pasting text while indent folding may mess up folds.
Solution: Adjust the way folds are split. (Brandon Simmons, closes #10254)
diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim
index e3b6b6e..3abb81a 100644
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -1439,4 +1439,24 @@
delfunc s:FoldText
endfunc
+" Make sure a fold containing a nested fold is split correctly when using
+" foldmethod=indent
+func Test_fold_split()
+ new
+ let lines =<< trim END
+ line 1
+ line 2
+ line 3
+ line 4
+ line 5
+ END
+ call setline(1, lines)
+ setlocal sw=2
+ setlocal foldmethod=indent foldenable
+ call assert_equal([0, 1, 1, 2, 2], range(1, 5)->map('foldlevel(v:val)'))
+ call append(2, 'line 2.5')
+ call assert_equal([0, 1, 0, 1, 2, 2], range(1, 6)->map('foldlevel(v:val)'))
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab