mirror of
https://github.com/vim/vim.git
synced 2025-10-02 05:04:20 -04:00
patch 8.1.1078: when 'listchars' is set a composing char on a space is wrong
Problem: When 'listchars' is set a composing char on a space is wrong. Solution: Separate handling a non-breaking space and a space. (Yasuhiro Matsumoto, closes #4046)
This commit is contained in:
28
src/screen.c
28
src/screen.c
@@ -4808,21 +4808,14 @@ win_line(
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 'list': change char 160 to lcs_nbsp and space to lcs_space.
|
||||
*/
|
||||
if (wp->w_p_list
|
||||
&& (((c == 160
|
||||
// 'list': change char 160 to lcs_nbsp and space to lcs_space.
|
||||
if (wp->w_p_list)
|
||||
{
|
||||
if ((c == 160
|
||||
|| (mb_utf8 && (mb_c == 160 || mb_c == 0x202f)))
|
||||
&& lcs_nbsp)
|
||||
|| (c == ' ' && lcs_space && ptr - line <= trailcol)))
|
||||
{
|
||||
c = (c == ' ') ? lcs_space : lcs_nbsp;
|
||||
if (area_attr == 0 && search_attr == 0)
|
||||
{
|
||||
n_attr = 1;
|
||||
extra_attr = HL_ATTR(HLF_8);
|
||||
saved_attr2 = char_attr; /* save current attr */
|
||||
}
|
||||
c = lcs_nbsp;
|
||||
mb_c = c;
|
||||
if (enc_utf8 && utf_char2len(c) > 1)
|
||||
{
|
||||
@@ -4833,6 +4826,17 @@ win_line(
|
||||
else
|
||||
mb_utf8 = FALSE;
|
||||
}
|
||||
else if (c == ' ' && lcs_space && ptr - line <= trailcol)
|
||||
{
|
||||
c = lcs_space;
|
||||
if (mb_utf8 == FALSE && area_attr == 0 && search_attr == 0)
|
||||
{
|
||||
n_attr = 1;
|
||||
extra_attr = HL_ATTR(HLF_8);
|
||||
saved_attr2 = char_attr; // save current attr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (trailcol != MAXCOL && ptr > line + trailcol && c == ' ')
|
||||
{
|
||||
|
@@ -113,3 +113,26 @@ func Test_listchars()
|
||||
enew!
|
||||
set listchars& ff&
|
||||
endfunc
|
||||
|
||||
func Test_listchars_composing()
|
||||
enew!
|
||||
let oldencoding=&encoding
|
||||
set encoding=utf-8
|
||||
set ff=unix
|
||||
set list
|
||||
|
||||
set listchars=eol:$,space:_
|
||||
call append(0, [
|
||||
\ " \u3099 \u309A"
|
||||
\ ])
|
||||
let expected = [
|
||||
\ "_ \u3099^I \u309A$"
|
||||
\ ]
|
||||
redraw!
|
||||
call cursor(1, 1)
|
||||
let got = ScreenLinesUtf8(1, virtcol('$'))
|
||||
bw!
|
||||
call assert_equal(expected, got)
|
||||
let &encoding=oldencoding
|
||||
set listchars& ff&
|
||||
endfunction
|
||||
|
@@ -775,6 +775,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1078,
|
||||
/**/
|
||||
1077,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user