Commit: patch 9.2.0964: 'isprint' is applied to the leading byte of a character
Christian Brabandt <[email protected]>
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <[email protected]> |
patch 9.2.0964: 'isprint' is applied to the leading byte of a character Commit: https://github.com/vim/vim/commit/2e6a408f3bc2b5dd83f883c56729cf57fe520762 Author: Hirohito Higashi <[email protected]> Date: Mon Aug 17 20:35:13 2026 +0000 patch 9.2.0964: 'isprint' is applied to the leading byte of a character Problem: Excluding a value with 'isprint' also breaks the display of unrelated characters whose leading byte has that value. After ":set isprint+=^226" the character U+222B is displayed as "<" (Emilien Breton). Solution: Apply 'isprint' to the character value only, not to the leading byte of its UTF-8 encoding (Hirohito Higashi). fixes: #21053 closes: #21055 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Hirohito Higashi <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/src/drawline.c b/src/drawline.c index c799291ba..edd5ef6ea 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -3325,8 +3325,9 @@ win_line( } } - // Handling of non-printable characters. - if (!vim_isprintc(c)) + // Handling of non-printable characters. 'isprint' does not apply + // to a UTF-8 leading byte, the character was checked above. + if (!vim_isprintc(c) && !(enc_utf8 && c >= 0x80)) { // when getting a character from the file, we may have to // turn it into something else on the way to putting it diff --git a/src/testdir/test_utf8.vim b/src/testdir/test_utf8.vim index 3070d4cc4..34bd9a801 100644 --- a/src/testdir/test_utf8.vim +++ b/src/testdir/test_utf8.vim @@ -388,4 +388,22 @@ func Test_overlong_utf8_cells() bwipe! endfunc +func Test_isprint_leading_byte() + new + let save_isprint = &isprint + " 226 is the leading byte of U+222B, which must not be affected. + set isprint+=^226 + call setline(1, "∫") + redraw + call assert_equal("∫", ScreenLines(1, 1)[0]) + + " U+00E2 has the character value 226 and is still excluded. + call setline(1, "â") + redraw + call assert_equal('<e2>', ScreenLines(1, 4)[0]) + + let &isprint = save_isprint + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 56e866a62..bd636ef46 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 964, /**/ 963, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1ww4Cf-00931c-NP%40256bit.org.