Skip to content

Commit 3aca5a6

Browse files
committed
patch 8.2.2524: cannot change the characters displayed in the foldcolumn
Problem: Cannot change the characters displayed in the foldcolumn. Solution: Add fields to 'fillchars'. (Yegappan Lakshmanan, Matthieu Coudron, closes #7860)
1 parent c0fcb6e commit 3aca5a6

6 files changed

Lines changed: 78 additions & 10 deletions

File tree

runtime/doc/options.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,6 +3247,9 @@ A jump table for the options with a short description can be found at |Q_op|.
32473247
stlnc:c ' ' or '=' statusline of the non-current windows
32483248
vert:c '|' vertical separators |:vsplit|
32493249
fold:c '-' filling 'foldtext'
3250+
foldopen:c '-' mark the beginning of a fold
3251+
foldclose:c '+' show a closed fold
3252+
foldsep:c '|' open fold middle character
32503253
diff:c '-' deleted lines of the 'diff' option
32513254
eob:c '~' empty lines below the end of a buffer
32523255

src/globals.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,9 @@ EXTERN int fill_stl INIT(= ' ');
13471347
EXTERN int fill_stlnc INIT(= ' ');
13481348
EXTERN int fill_vert INIT(= ' ');
13491349
EXTERN int fill_fold INIT(= '-');
1350+
EXTERN int fill_foldopen INIT(= '-');
1351+
EXTERN int fill_foldclosed INIT(= '+');
1352+
EXTERN int fill_foldsep INIT(= '|');
13501353
EXTERN int fill_diff INIT(= '-');
13511354
EXTERN int fill_eob INIT(= '~');
13521355

src/mouse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1989,7 +1989,7 @@ jump_to_mouse(
19891989
count |= CURSOR_MOVED; // Cursor has moved
19901990

19911991
# ifdef FEAT_FOLDING
1992-
if (mouse_char == '+')
1992+
if (mouse_char == fill_foldclosed)
19931993
count |= MOUSE_FOLD_OPEN;
19941994
else if (mouse_char != ' ')
19951995
count |= MOUSE_FOLD_CLOSE;

src/screen.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,9 @@ fill_foldcolumn(
272272
{
273273
if (win_foldinfo.fi_lnum == lnum
274274
&& first_level + i >= win_foldinfo.fi_low_level)
275-
p[i] = '-';
275+
p[i] = fill_foldopen;
276276
else if (first_level == 1)
277-
p[i] = '|';
277+
p[i] = fill_foldsep;
278278
else if (first_level + i <= 9)
279279
p[i] = '0' + first_level + i;
280280
else
@@ -284,7 +284,7 @@ fill_foldcolumn(
284284
}
285285
}
286286
if (closed)
287-
p[i >= fdc ? i - 1 : i] = '+';
287+
p[i >= fdc ? i - 1 : i] = fill_foldclosed;
288288
}
289289
#endif // FEAT_FOLDING
290290

@@ -4761,12 +4761,15 @@ set_chars_option(win_T *wp, char_u **varp)
47614761
};
47624762
static struct charstab filltab[] =
47634763
{
4764-
{&fill_stl, "stl"},
4765-
{&fill_stlnc, "stlnc"},
4766-
{&fill_vert, "vert"},
4767-
{&fill_fold, "fold"},
4768-
{&fill_diff, "diff"},
4769-
{&fill_eob, "eob"},
4764+
{&fill_stl, "stl"},
4765+
{&fill_stlnc, "stlnc"},
4766+
{&fill_vert, "vert"},
4767+
{&fill_fold, "fold"},
4768+
{&fill_foldopen, "foldopen"},
4769+
{&fill_foldclosed, "foldclose"},
4770+
{&fill_foldsep, "foldsep"},
4771+
{&fill_diff, "diff"},
4772+
{&fill_eob, "eob"},
47704773
};
47714774
static lcs_chars_T lcs_chars;
47724775
struct charstab lcstab[] =
@@ -4821,6 +4824,9 @@ set_chars_option(win_T *wp, char_u **varp)
48214824
else
48224825
{
48234826
fill_diff = '-';
4827+
fill_foldopen = '-';
4828+
fill_foldclosed = '+';
4829+
fill_foldsep = '|';
48244830
fill_eob = '~';
48254831
}
48264832
}

src/testdir/test_display.vim

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,58 @@ func Test_eob_fillchars()
279279
close
280280
endfunc
281281

282+
" Test for 'foldopen', 'foldclose' and 'foldsep' in 'fillchars'
283+
func Test_fold_fillchars()
284+
new
285+
set fdc=2 foldenable foldmethod=manual
286+
call setline(1, ['one', 'two', 'three', 'four', 'five'])
287+
2,4fold
288+
" First check for the default setting for a closed fold
289+
let lines = ScreenLines([1, 3], 8)
290+
let expected = [
291+
\ ' one ',
292+
\ '+ +-- 3',
293+
\ ' five '
294+
\ ]
295+
call assert_equal(expected, lines)
296+
normal 2Gzo
297+
" check the characters for an open fold
298+
let lines = ScreenLines([1, 5], 8)
299+
let expected = [
300+
\ ' one ',
301+
\ '- two ',
302+
\ '| three ',
303+
\ '| four ',
304+
\ ' five '
305+
\ ]
306+
call assert_equal(expected, lines)
307+
308+
" change the setting
309+
set fillchars=vert:\|,fold:-,eob:~,foldopen:[,foldclose:],foldsep:-
310+
311+
" check the characters for an open fold
312+
let lines = ScreenLines([1, 5], 8)
313+
let expected = [
314+
\ ' one ',
315+
\ '[ two ',
316+
\ '- three ',
317+
\ '- four ',
318+
\ ' five '
319+
\ ]
320+
call assert_equal(expected, lines)
321+
322+
" check the characters for a closed fold
323+
normal 2Gzc
324+
let lines = ScreenLines([1, 3], 8)
325+
let expected = [
326+
\ ' one ',
327+
\ '] +-- 3',
328+
\ ' five '
329+
\ ]
330+
call assert_equal(expected, lines)
331+
332+
%bw!
333+
set fillchars& fdc& foldmethod& foldenable&
334+
endfunc
335+
282336
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2524,
753755
/**/
754756
2523,
755757
/**/

0 commit comments

Comments
 (0)