]> granicus.if.org Git - vim/commitdiff
patch 8.2.2524: cannot change the characters displayed in the foldcolumn v8.2.2524
authorBram Moolenaar <Bram@vim.org>
Wed, 17 Feb 2021 12:14:07 +0000 (13:14 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 17 Feb 2021 12:14:07 +0000 (13:14 +0100)
Problem:    Cannot change the characters displayed in the foldcolumn.
Solution:   Add fields to 'fillchars'. (Yegappan Lakshmanan, Matthieu Coudron,
            closes #7860)

runtime/doc/options.txt
src/globals.h
src/mouse.c
src/screen.c
src/testdir/test_display.vim
src/version.c

index d5264ecff9579f014254006e1122d6eb26e6c445..70746082cfe70a165f054354a731dd3dcb3c8855 100644 (file)
@@ -3247,6 +3247,9 @@ A jump table for the options with a short description can be found at |Q_op|.
          stlnc:c       ' ' or '='      statusline of the non-current windows
          vert:c        '|'             vertical separators |:vsplit|
          fold:c        '-'             filling 'foldtext'
+         foldopen:c    '-'             mark the beginning of a fold
+         foldclose:c   '+'             show a closed fold
+         foldsep:c     '|'             open fold middle character
          diff:c        '-'             deleted lines of the 'diff' option
          eob:c         '~'             empty lines below the end of a buffer
 
index bc4a3d5d539387d5815d65921688f53e677a40ec..0fd08b63173af868b857eb885f2c8067fb715b6b 100644 (file)
@@ -1347,6 +1347,9 @@ EXTERN int        fill_stl INIT(= ' ');
 EXTERN int     fill_stlnc INIT(= ' ');
 EXTERN int     fill_vert INIT(= ' ');
 EXTERN int     fill_fold INIT(= '-');
+EXTERN int     fill_foldopen INIT(= '-');
+EXTERN int     fill_foldclosed INIT(= '+');
+EXTERN int     fill_foldsep INIT(= '|');
 EXTERN int     fill_diff INIT(= '-');
 EXTERN int     fill_eob INIT(= '~');
 
index 10b991b983de8579d1955549391c1992ebec2f1f..4bff48e768d968281ddc5ff3a57e821c3c62199a 100644 (file)
@@ -1989,7 +1989,7 @@ retnomove:
        count |= CURSOR_MOVED;          // Cursor has moved
 
 # ifdef FEAT_FOLDING
-    if (mouse_char == '+')
+    if (mouse_char == fill_foldclosed)
        count |= MOUSE_FOLD_OPEN;
     else if (mouse_char != ' ')
        count |= MOUSE_FOLD_CLOSE;
index b6cc9bd91d5556d569508c377dff2bf5d96e47be..a012c70037f119c742aa58be84825f6163fe5ac9 100644 (file)
@@ -272,9 +272,9 @@ fill_foldcolumn(
        {
            if (win_foldinfo.fi_lnum == lnum
                              && first_level + i >= win_foldinfo.fi_low_level)
-               p[i] = '-';
+               p[i] = fill_foldopen;
            else if (first_level == 1)
-               p[i] = '|';
+               p[i] = fill_foldsep;
            else if (first_level + i <= 9)
                p[i] = '0' + first_level + i;
            else
@@ -284,7 +284,7 @@ fill_foldcolumn(
        }
     }
     if (closed)
-       p[i >= fdc ? i - 1 : i] = '+';
+       p[i >= fdc ? i - 1 : i] = fill_foldclosed;
 }
 #endif // FEAT_FOLDING
 
@@ -4761,12 +4761,15 @@ set_chars_option(win_T *wp, char_u **varp)
     };
     static struct charstab filltab[] =
     {
-       {&fill_stl,     "stl"},
-       {&fill_stlnc,   "stlnc"},
-       {&fill_vert,    "vert"},
-       {&fill_fold,    "fold"},
-       {&fill_diff,    "diff"},
-       {&fill_eob,     "eob"},
+       {&fill_stl,             "stl"},
+       {&fill_stlnc,           "stlnc"},
+       {&fill_vert,            "vert"},
+       {&fill_fold,            "fold"},
+       {&fill_foldopen,        "foldopen"},
+       {&fill_foldclosed,      "foldclose"},
+       {&fill_foldsep,         "foldsep"},
+       {&fill_diff,            "diff"},
+       {&fill_eob,             "eob"},
     };
     static lcs_chars_T lcs_chars;
     struct charstab lcstab[] =
@@ -4821,6 +4824,9 @@ set_chars_option(win_T *wp, char_u **varp)
            else
            {
                fill_diff = '-';
+               fill_foldopen = '-';
+               fill_foldclosed = '+';
+               fill_foldsep = '|';
                fill_eob = '~';
            }
        }
index 5bf9e5eac8806778f62e4834ada21bae2ddd7e60..4616da5653b491d50bc02194fcff4a508d0b4d63 100644 (file)
@@ -279,4 +279,58 @@ func Test_eob_fillchars()
   close
 endfunc
 
+" Test for 'foldopen', 'foldclose' and 'foldsep' in 'fillchars'
+func Test_fold_fillchars()
+  new
+  set fdc=2 foldenable foldmethod=manual
+  call setline(1, ['one', 'two', 'three', 'four', 'five'])
+  2,4fold
+  " First check for the default setting for a closed fold
+  let lines = ScreenLines([1, 3], 8)
+  let expected = [
+        \ '  one   ',
+        \ '+ +--  3',
+        \ '  five  '
+        \ ]
+  call assert_equal(expected, lines)
+  normal 2Gzo
+  " check the characters for an open fold
+  let lines = ScreenLines([1, 5], 8)
+  let expected = [
+        \ '  one   ',
+        \ '- two   ',
+        \ '| three ',
+        \ '| four  ',
+        \ '  five  '
+        \ ]
+  call assert_equal(expected, lines)
+
+  " change the setting
+  set fillchars=vert:\|,fold:-,eob:~,foldopen:[,foldclose:],foldsep:-
+
+  " check the characters for an open fold
+  let lines = ScreenLines([1, 5], 8)
+  let expected = [
+        \ '  one   ',
+        \ '[ two   ',
+        \ '- three ',
+        \ '- four  ',
+        \ '  five  '
+        \ ]
+  call assert_equal(expected, lines)
+
+  " check the characters for a closed fold
+  normal 2Gzc
+  let lines = ScreenLines([1, 3], 8)
+  let expected = [
+        \ '  one   ',
+        \ '] +--  3',
+        \ '  five  '
+        \ ]
+  call assert_equal(expected, lines)
+
+  %bw!
+  set fillchars& fdc& foldmethod& foldenable&
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 265cf31698eb92dcfc361962ff92dff3bfea500d..26f80cc992d7b0c545601060bc9a003ecf41bc2c 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2524,
 /**/
     2523,
 /**/