diff src/testdir/test_mksession.vim @ 24287:c2a234e8c896 v8.2.2684

patch 8.2.2684: not enough folding code is tested Commit: https://github.com/vim/vim/commit/5c504f680e63120fea36becfabb8d939d4449e34 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 1 13:39:51 2021 +0200 patch 8.2.2684: not enough folding code is tested Problem: Not enough folding code is tested. Solution: Add more test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8046)
author Bram Moolenaar <Bram@vim.org>
date Thu, 01 Apr 2021 13:45:02 +0200
parents 3b5d499c2bb5
children 3f96a5dc0c53
line wrap: on
line diff
--- a/src/testdir/test_mksession.vim
+++ b/src/testdir/test_mksession.vim
@@ -997,4 +997,35 @@ func Test_altfile()
   call delete('Xtest_altfile')
 endfunc
 
+" Test for creating views with manual folds
+func Test_mkview_manual_fold()
+  call writefile(range(1,10), 'Xfile')
+  new Xfile
+  " create recursive folds
+  5,6fold
+  4,7fold
+  mkview Xview
+  normal zE
+  source Xview
+  call assert_equal([-1, 4, 4, 4, 4, -1], [foldclosed(3), foldclosed(4),
+        \ foldclosed(5), foldclosed(6), foldclosed(7), foldclosed(8)])
+  " open one level of fold
+  4foldopen
+  mkview! Xview
+  normal zE
+  source Xview
+  call assert_equal([-1, -1, 5, 5, -1, -1], [foldclosed(3), foldclosed(4),
+        \ foldclosed(5), foldclosed(6), foldclosed(7), foldclosed(8)])
+  " open all the folds
+  %foldopen!
+  mkview! Xview
+  normal zE
+  source Xview
+  call assert_equal([-1, -1, -1, -1, -1, -1], [foldclosed(3), foldclosed(4),
+        \ foldclosed(5), foldclosed(6), foldclosed(7), foldclosed(8)])
+  call delete('Xfile')
+  call delete('Xview')
+  bw!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab