mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.2569: 'fillchars' "stl" and "stlnc" items must be single byte
Problem: 'fillchars' "stl" and "stlnc" items must be single byte. Solution: Accept multi-byte characters. (Christian Wellenbrock, Yegappan Lakshmanan, closes #7927)
This commit is contained in:
parent
6057748a1a
commit
008bff967f
@ -3262,7 +3262,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
< This is similar to the default, except that these characters will also
|
< This is similar to the default, except that these characters will also
|
||||||
be used when there is highlighting.
|
be used when there is highlighting.
|
||||||
|
|
||||||
for "stl" and "stlnc" only single-byte values are supported.
|
For "stl" and "stlnc" single-byte and multibyte characters are
|
||||||
|
supported. But double-width characters are not supported.
|
||||||
|
|
||||||
The highlighting used for these items:
|
The highlighting used for these items:
|
||||||
item highlight group ~
|
item highlight group ~
|
||||||
|
41
src/buffer.c
41
src/buffer.c
@ -4157,9 +4157,6 @@ build_stl_str_hl(
|
|||||||
|
|
||||||
if (fillchar == 0)
|
if (fillchar == 0)
|
||||||
fillchar = ' ';
|
fillchar = ' ';
|
||||||
// Can't handle a multi-byte fill character yet.
|
|
||||||
else if (mb_char2len(fillchar) > 1)
|
|
||||||
fillchar = '-';
|
|
||||||
|
|
||||||
// The cursor in windows other than the current one isn't always
|
// The cursor in windows other than the current one isn't always
|
||||||
// up-to-date, esp. because of autocommands and timers.
|
// up-to-date, esp. because of autocommands and timers.
|
||||||
@ -4335,7 +4332,7 @@ build_stl_str_hl(
|
|||||||
|
|
||||||
// Fill up space left over by half a double-wide char.
|
// Fill up space left over by half a double-wide char.
|
||||||
while (++l < stl_items[stl_groupitem[groupdepth]].stl_minwid)
|
while (++l < stl_items[stl_groupitem[groupdepth]].stl_minwid)
|
||||||
*p++ = fillchar;
|
MB_CHAR2BYTES(fillchar, p);
|
||||||
|
|
||||||
// correct the start of the items for the truncation
|
// correct the start of the items for the truncation
|
||||||
for (l = stl_groupitem[groupdepth] + 1; l < curitem; l++)
|
for (l = stl_groupitem[groupdepth] + 1; l < curitem; l++)
|
||||||
@ -4354,20 +4351,20 @@ build_stl_str_hl(
|
|||||||
// fill by appending characters
|
// fill by appending characters
|
||||||
n = 0 - n;
|
n = 0 - n;
|
||||||
while (l++ < n && p + 1 < out + outlen)
|
while (l++ < n && p + 1 < out + outlen)
|
||||||
*p++ = fillchar;
|
MB_CHAR2BYTES(fillchar, p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// fill by inserting characters
|
// fill by inserting characters
|
||||||
mch_memmove(t + n - l, t, (size_t)(p - t));
|
l = (n - l) * MB_CHAR2LEN(fillchar);
|
||||||
l = n - l;
|
mch_memmove(t + l, t, (size_t)(p - t));
|
||||||
if (p + l >= out + outlen)
|
if (p + l >= out + outlen)
|
||||||
l = (long)((out + outlen) - p - 1);
|
l = (long)((out + outlen) - p - 1);
|
||||||
p += l;
|
p += l;
|
||||||
for (n = stl_groupitem[groupdepth] + 1; n < curitem; n++)
|
for (n = stl_groupitem[groupdepth] + 1; n < curitem; n++)
|
||||||
stl_items[n].stl_start += l;
|
stl_items[n].stl_start += l;
|
||||||
for ( ; l > 0; l--)
|
for ( ; l > 0; l--)
|
||||||
*t++ = fillchar;
|
MB_CHAR2BYTES(fillchar, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -4746,23 +4743,24 @@ build_stl_str_hl(
|
|||||||
if (l + 1 == minwid && fillchar == '-' && VIM_ISDIGIT(*t))
|
if (l + 1 == minwid && fillchar == '-' && VIM_ISDIGIT(*t))
|
||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
else
|
else
|
||||||
*p++ = fillchar;
|
MB_CHAR2BYTES(fillchar, p);
|
||||||
}
|
}
|
||||||
minwid = 0;
|
minwid = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
minwid *= -1;
|
minwid *= -1;
|
||||||
while (*t && p + 1 < out + outlen)
|
for (; *t && p + 1 < out + outlen; t++)
|
||||||
{
|
{
|
||||||
*p++ = *t++;
|
|
||||||
// Change a space by fillchar, unless fillchar is '-' and a
|
// Change a space by fillchar, unless fillchar is '-' and a
|
||||||
// digit follows.
|
// digit follows.
|
||||||
if (fillable && p[-1] == ' '
|
if (fillable && *t == ' '
|
||||||
&& (!VIM_ISDIGIT(*t) || fillchar != '-'))
|
&& (!VIM_ISDIGIT(*(t + 1)) || fillchar != '-'))
|
||||||
p[-1] = fillchar;
|
MB_CHAR2BYTES(fillchar, p);
|
||||||
|
else
|
||||||
|
*p++ = *t;
|
||||||
}
|
}
|
||||||
for (; l < minwid && p + 1 < out + outlen; l++)
|
for (; l < minwid && p + 1 < out + outlen; l++)
|
||||||
*p++ = fillchar;
|
MB_CHAR2BYTES(fillchar, p);
|
||||||
}
|
}
|
||||||
else if (num >= 0)
|
else if (num >= 0)
|
||||||
{
|
{
|
||||||
@ -4865,7 +4863,7 @@ build_stl_str_hl(
|
|||||||
}
|
}
|
||||||
// Fill up for half a double-wide character.
|
// Fill up for half a double-wide character.
|
||||||
while (++width < maxwidth)
|
while (++width < maxwidth)
|
||||||
*s++ = fillchar;
|
MB_CHAR2BYTES(fillchar, s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
s = out + maxwidth - 1;
|
s = out + maxwidth - 1;
|
||||||
@ -4897,7 +4895,7 @@ build_stl_str_hl(
|
|||||||
while (++width < maxwidth)
|
while (++width < maxwidth)
|
||||||
{
|
{
|
||||||
s = s + STRLEN(s);
|
s = s + STRLEN(s);
|
||||||
*s++ = fillchar;
|
MB_CHAR2BYTES(fillchar, s);
|
||||||
*s = NUL;
|
*s = NUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4920,12 +4918,13 @@ build_stl_str_hl(
|
|||||||
break;
|
break;
|
||||||
if (l < itemcnt)
|
if (l < itemcnt)
|
||||||
{
|
{
|
||||||
p = stl_items[l].stl_start + maxwidth - width;
|
int middlelength = (maxwidth - width) * MB_CHAR2LEN(fillchar);
|
||||||
|
p = stl_items[l].stl_start + middlelength;
|
||||||
STRMOVE(p, stl_items[l].stl_start);
|
STRMOVE(p, stl_items[l].stl_start);
|
||||||
for (s = stl_items[l].stl_start; s < p; s++)
|
for (s = stl_items[l].stl_start; s < p;)
|
||||||
*s = fillchar;
|
MB_CHAR2BYTES(fillchar, s);
|
||||||
for (l++; l < itemcnt; l++)
|
for (l++; l < itemcnt; l++)
|
||||||
stl_items[l].stl_start += maxwidth - width;
|
stl_items[l].stl_start += middlelength;
|
||||||
width = maxwidth;
|
width = maxwidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,6 +252,7 @@
|
|||||||
#define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
|
#define MB_CHARLEN(p) (has_mbyte ? mb_charlen(p) : (int)STRLEN(p))
|
||||||
#define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1)
|
#define MB_CHAR2LEN(c) (has_mbyte ? mb_char2len(c) : 1)
|
||||||
#define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
|
#define PTR2CHAR(p) (has_mbyte ? mb_ptr2char(p) : (int)*(p))
|
||||||
|
#define MB_CHAR2BYTES(c, b) do { if (has_mbyte) (b) += (*mb_char2bytes)((c), (b)); else *(b)++ = (c); } while(0)
|
||||||
|
|
||||||
#ifdef FEAT_AUTOCHDIR
|
#ifdef FEAT_AUTOCHDIR
|
||||||
# define DO_AUTOCHDIR do { if (p_acd) do_autochdir(); } while (0)
|
# define DO_AUTOCHDIR do { if (p_acd) do_autochdir(); } while (0)
|
||||||
|
@ -266,7 +266,7 @@ fill_foldcolumn(
|
|||||||
empty = (fdc == 1) ? 0 : 1;
|
empty = (fdc == 1) ? 0 : 1;
|
||||||
|
|
||||||
// If the column is too narrow, we start at the lowest level that
|
// If the column is too narrow, we start at the lowest level that
|
||||||
// fits and use numbers to indicated the depth.
|
// fits and use numbers to indicate the depth.
|
||||||
first_level = level - fdc - closed + 1 + empty;
|
first_level = level - fdc - closed + 1 + empty;
|
||||||
if (first_level < 1)
|
if (first_level < 1)
|
||||||
first_level = 1;
|
first_level = 1;
|
||||||
|
@ -987,7 +987,66 @@ func s:mbyte_fillchar_tests(fo, fc, fs)
|
|||||||
\ a:fs .. 'six ',
|
\ a:fs .. 'six ',
|
||||||
\ ], ScreenLines([1, 6], 7))
|
\ ], ScreenLines([1, 6], 7))
|
||||||
|
|
||||||
setlocal foldcolumn&
|
" Enable number and sign columns and place some signs
|
||||||
|
setlocal fdc=3
|
||||||
|
setlocal number
|
||||||
|
setlocal signcolumn=auto
|
||||||
|
sign define S1 text=->
|
||||||
|
sign place 10 line=3 name=S1
|
||||||
|
call assert_equal([
|
||||||
|
\ a:fo .. ' 1 one ',
|
||||||
|
\ a:fs .. a:fo .. ' 2 two ',
|
||||||
|
\ '2' .. a:fo .. ' -> 3 three',
|
||||||
|
\ '23 4 four ',
|
||||||
|
\ a:fs .. a:fs .. ' 5 five ',
|
||||||
|
\ a:fs .. ' 6 six '
|
||||||
|
\ ], ScreenLines([1, 6], 14))
|
||||||
|
|
||||||
|
" Test with 'rightleft'
|
||||||
|
if has('rightleft')
|
||||||
|
setlocal rightleft
|
||||||
|
let lines = ScreenLines([1, 6], winwidth(0))
|
||||||
|
call assert_equal('o 1 ' .. a:fo,
|
||||||
|
\ strcharpart(lines[0], strchars(lines[0]) - 10, 10))
|
||||||
|
call assert_equal('t 2 ' .. a:fo .. a:fs,
|
||||||
|
\ strcharpart(lines[1], strchars(lines[1]) - 10, 10))
|
||||||
|
call assert_equal('t 3 >- ' .. a:fo .. '2',
|
||||||
|
\ strcharpart(lines[2], strchars(lines[2]) - 10, 10))
|
||||||
|
call assert_equal('f 4 32',
|
||||||
|
\ strcharpart(lines[3], strchars(lines[3]) - 10, 10))
|
||||||
|
call assert_equal('f 5 ' .. a:fs .. a:fs,
|
||||||
|
\ strcharpart(lines[4], strchars(lines[4]) - 10, 10))
|
||||||
|
call assert_equal('s 6 ' .. a:fs,
|
||||||
|
\ strcharpart(lines[5], strchars(lines[5]) - 10, 10))
|
||||||
|
setlocal norightleft
|
||||||
|
endif
|
||||||
|
|
||||||
|
sign unplace *
|
||||||
|
sign undefine S1
|
||||||
|
setlocal number& signcolumn&
|
||||||
|
|
||||||
|
" Add a test with more than 9 folds (and then delete some folds)
|
||||||
|
normal zE
|
||||||
|
for i in range(1, 10)
|
||||||
|
normal zfGzo
|
||||||
|
endfor
|
||||||
|
normal zR
|
||||||
|
call assert_equal([
|
||||||
|
\ a:fo .. a:fo .. ' one ',
|
||||||
|
\ '9> two '
|
||||||
|
\ ], ScreenLines([1, 2], 7))
|
||||||
|
normal 1Gzd
|
||||||
|
call assert_equal([
|
||||||
|
\ a:fo .. a:fo .. ' one ',
|
||||||
|
\ '89 two '
|
||||||
|
\ ], ScreenLines([1, 2], 7))
|
||||||
|
normal 1Gzdzdzdzdzdzdzd
|
||||||
|
call assert_equal([
|
||||||
|
\ a:fo .. a:fo .. ' one ',
|
||||||
|
\ a:fs .. a:fs .. ' two '
|
||||||
|
\ ], ScreenLines([1, 2], 7))
|
||||||
|
|
||||||
|
setlocal foldcolumn& number& signcolumn&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_foldcolumn_multibyte_char()
|
func Test_foldcolumn_multibyte_char()
|
||||||
|
@ -464,5 +464,20 @@ func Test_statusline_after_split_vsplit()
|
|||||||
set ls& stl&
|
set ls& stl&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test using a multibyte character for 'stl' and 'stlnc' items in 'fillchars'
|
||||||
|
" with a custom 'statusline'
|
||||||
|
func Test_statusline_mbyte_fillchar()
|
||||||
|
only
|
||||||
|
set laststatus=2
|
||||||
|
set fillchars=vert:\|,fold:-,stl:━,stlnc:═
|
||||||
|
set statusline=a%=b
|
||||||
|
call assert_match('^a\+━\+b$', s:get_statusline())
|
||||||
|
vnew
|
||||||
|
call assert_match('^a\+━\+b━a\+═\+b$', s:get_statusline())
|
||||||
|
wincmd w
|
||||||
|
call assert_match('^a\+═\+b═a\+━\+b$', s:get_statusline())
|
||||||
|
set statusline& fillchars& laststatus&
|
||||||
|
%bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2569,
|
||||||
/**/
|
/**/
|
||||||
2568,
|
2568,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user