@@ -894,4 +894,116 @@ func Test_fold_relative_move()
894894 set fdm & sw & wrap & tw &
895895endfunc
896896
897+ " Test for using multibyte characters as 'foldopen', 'foldclose' and
898+ " 'foldsetp' items in 'fillchars'
899+ func s: mbyte_fillchar_tests (fo , fc, fs )
900+ setlocal foldcolumn = 3
901+
902+ normal zE
903+ 1 ,2 fold
904+ call assert_equal ([a: fc .. ' +-- 2 ' , ' three ' ],
905+ \ ScreenLines ([1 , 2 ], 10 ))
906+ 1 ,2 foldopen
907+ call assert_equal ([a: fo .. ' one ' , a: fs .. ' two ' ],
908+ \ ScreenLines ([1 , 2 ], 7 ))
909+ 1 ,2 foldclose
910+ redraw !
911+ call assert_equal ([a: fc .. ' +-- 2 ' , ' three ' ],
912+ \ ScreenLines ([1 , 2 ], 10 ))
913+
914+ " Two level fold
915+ normal zE
916+ 2 ,3 fold
917+ 1 ,4 fold
918+ call assert_equal ([a: fc .. ' +-- 4 ' , ' five ' ],
919+ \ ScreenLines ([1 , 2 ], 10 ))
920+ 1 ,4 foldopen
921+ call assert_equal ([a: fo .. ' one ' , a: fs .. a: fc .. ' +--- 2' ],
922+ \ ScreenLines ([1 , 2 ], 10 ))
923+ 1 ,4 foldopen
924+ call assert_equal ([a: fo .. ' one ' , a: fs .. a: fo .. ' two ' ,
925+ \ a: fs .. a: fs .. ' three ' ], ScreenLines ([1 , 3 ], 10 ))
926+ 2 ,3 foldclose
927+ call assert_equal ([a: fo .. ' one ' , a: fs .. a: fc .. ' +--- 2' ],
928+ \ ScreenLines ([1 , 2 ], 10 ))
929+ 1 ,4 foldclose
930+ call assert_equal ([a: fc .. ' +-- 4 ' , ' five ' ],
931+ \ ScreenLines ([1 , 2 ], 10 ))
932+
933+ " Three level fold
934+ normal zE
935+ 3 ,4 fold
936+ 2 ,5 fold
937+ 1 ,6 fold
938+ call assert_equal ([a: fc .. ' +-- 6 ' ], ScreenLines (1 , 10 ))
939+ " open all the folds
940+ normal zR
941+ call assert_equal ([
942+ \ a: fo .. ' one ' ,
943+ \ a: fs .. a: fo .. ' two ' ,
944+ \ ' 2' .. a: fo .. ' three ' ,
945+ \ ' 23 four ' ,
946+ \ a: fs .. a: fs .. ' five ' ,
947+ \ a: fs .. ' six ' ,
948+ \ ], ScreenLines ([1 , 6 ], 10 ))
949+ " close the innermost fold
950+ 3 ,4 foldclose
951+ call assert_equal ([
952+ \ a: fo .. ' one ' ,
953+ \ a: fs .. a: fo .. ' two ' ,
954+ \ a: fs .. a: fs .. a: fc .. ' +---- ' ,
955+ \ a: fs .. a: fs .. ' five ' ,
956+ \ a: fs .. ' six ' ,
957+ \ ], ScreenLines ([1 , 5 ], 10 ))
958+ " close the next fold
959+ 2 ,5 foldclose
960+ call assert_equal ([
961+ \ a: fo .. ' one ' ,
962+ \ a: fs .. a: fc .. ' +--- 4' ,
963+ \ a: fs .. ' six ' ,
964+ \ ], ScreenLines ([1 , 3 ], 10 ))
965+
966+ " set the fold column size to 2
967+ setlocal fdc = 2
968+ normal zR
969+ call assert_equal ([
970+ \ a: fo .. ' one ' ,
971+ \ a: fo .. ' two ' ,
972+ \ a: fo .. ' three' ,
973+ \ ' 3 four ' ,
974+ \ ' 2 five ' ,
975+ \ a: fs .. ' six ' ,
976+ \ ], ScreenLines ([1 , 6 ], 7 ))
977+
978+ " set the fold column size to 1
979+ setlocal fdc = 1
980+ normal zR
981+ call assert_equal ([
982+ \ a: fo .. ' one ' ,
983+ \ a: fo .. ' two ' ,
984+ \ a: fo .. ' three ' ,
985+ \ ' 3four ' ,
986+ \ ' 2five ' ,
987+ \ a: fs .. ' six ' ,
988+ \ ], ScreenLines ([1 , 6 ], 7 ))
989+
990+ setlocal foldcolumn &
991+ endfunc
992+
993+ func Test_foldcolumn_multibyte_char ()
994+ new
995+ call setline (1 , [' one' , ' two' , ' three' , ' four' , ' five' , ' six' ])
996+ setlocal foldenable foldmethod = manual
997+
998+ " First test with the default setting
999+ call s: mbyte_fillchar_tests (' -' , ' +' , ' |' )
1000+
1001+ " Use multi-byte characters
1002+ set fillchars += foldopen :▾,foldsep:│,foldclose :▸
1003+ call s: mbyte_fillchar_tests (' ▾' , ' ▸' , ' │' )
1004+
1005+ bw !
1006+ set foldenable & fdc & fdm & fillchars &
1007+ endfunc
1008+
8971009" vim: shiftwidth = 2 sts = 2 expandtab
0 commit comments