diff options
author | zeertzjq <zeertzjq@outlook.com> | 2021-09-19 13:13:44 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2021-09-19 13:13:44 +0800 |
commit | 32663b0f7e5911a8bced6b65dfc43622aadba198 (patch) | |
tree | 4b340152f79e11f2f0b915477890e32e1c6bad5f /src | |
parent | 963474321bcc02a5698c40b4677cd36ab8d4cebc (diff) | |
download | rneovim-32663b0f7e5911a8bced6b65dfc43622aadba198.tar.gz rneovim-32663b0f7e5911a8bced6b65dfc43622aadba198.tar.bz2 rneovim-32663b0f7e5911a8bced6b65dfc43622aadba198.zip |
vim-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 vim/vim#4046)
https://github.com/vim/vim/commit/5f8069bbf5d989936a2f4d7a76ae42434017e3a2
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/screen.c | 40 | ||||
-rw-r--r-- | src/nvim/testdir/test_listchars.vim | 23 |
2 files changed, 45 insertions, 18 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c index e1846d4569..5ce8e0b348 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -3581,24 +3581,28 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc } // 'list': change char 160 to 'nbsp' and space to 'space'. - if (wp->w_p_list - && (((c == 160 - || (mb_utf8 && (mb_c == 160 || mb_c == 0x202f))) - && curwin->w_p_lcs_chars.nbsp) - || (c == ' ' && curwin->w_p_lcs_chars.space - && ptr - line >= leadcol - && ptr - line <= trailcol))) { - c = (c == ' ') ? wp->w_p_lcs_chars.space : wp->w_p_lcs_chars.nbsp; - n_attr = 1; - extra_attr = win_hl_attr(wp, HLF_0); - saved_attr2 = char_attr; // save current attr - mb_c = c; - if (utf_char2len(c) > 1) { - mb_utf8 = true; - u8cc[0] = 0; - c = 0xc0; - } else { - mb_utf8 = false; + if (wp->w_p_list) { + if ((c == 160 || (mb_utf8 && (mb_c == 160 || mb_c == 0x202f))) + && wp->w_p_lcs_chars.nbsp) { + c = wp->w_p_lcs_chars.nbsp; + mb_c = c; + if (utf_char2len(c) > 1) { + mb_utf8 = true; + u8cc[0] = 0; + c = 0xc0; + } else { + mb_utf8 = false; + } + } else if (c == ' ' + && wp->w_p_lcs_chars.space + && ptr - line >= leadcol + && ptr - line <= trailcol) { + c = wp->w_p_lcs_chars.space; + if (mb_utf8 == false) { + n_attr = 1; + extra_attr = win_hl_attr(wp, HLF_0); + saved_attr2 = char_attr; // save current attr + } } } diff --git a/src/nvim/testdir/test_listchars.vim b/src/nvim/testdir/test_listchars.vim index 4cb609aaf0..191e2afdf1 100644 --- a/src/nvim/testdir/test_listchars.vim +++ b/src/nvim/testdir/test_listchars.vim @@ -181,3 +181,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 |