summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-02-17 13:14:07 +0100
committerBram Moolenaar <Bram@vim.org>2021-02-17 13:14:07 +0100
commit3aca5a6fbcfbf5f4492b9ea0c4308ac524d33606 (patch)
treee5d533698b1e46e544e37e1c1c389ec4e6fde482 /src
parentc0fcb6e0b10050145e7d334b68b1bdc5201fed05 (diff)
downloadvim-git-3aca5a6fbcfbf5f4492b9ea0c4308ac524d33606.tar.gz
patch 8.2.2524: cannot change the characters displayed in the foldcolumnv8.2.2524
Problem: Cannot change the characters displayed in the foldcolumn. Solution: Add fields to 'fillchars'. (Yegappan Lakshmanan, Matthieu Coudron, closes #7860)
Diffstat (limited to 'src')
-rw-r--r--src/globals.h3
-rw-r--r--src/mouse.c2
-rw-r--r--src/screen.c24
-rw-r--r--src/testdir/test_display.vim54
-rw-r--r--src/version.c2
5 files changed, 75 insertions, 10 deletions
diff --git a/src/globals.h b/src/globals.h
index bc4a3d5d5..0fd08b631 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -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(= '~');
diff --git a/src/mouse.c b/src/mouse.c
index 10b991b98..4bff48e76 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -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;
diff --git a/src/screen.c b/src/screen.c
index b6cc9bd91..a012c7003 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -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 = '~';
}
}
diff --git a/src/testdir/test_display.vim b/src/testdir/test_display.vim
index 5bf9e5eac..4616da565 100644
--- a/src/testdir/test_display.vim
+++ b/src/testdir/test_display.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 265cf3169..26f80cc99 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2524,
+/**/
2523,
/**/
2522,