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) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Hirohito HigashiandClaude Opus 5 authored and Christian Brabandt committed 2026-08-17 20:35:13 +00:00
1 parent 6ac008db96
commit 2e6a408f3b
3 files changed
+23 -2

No files matched your search

+3 -2
View File
@@ -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
+18
View File
@@ -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
+2
View File
@@ -763,6 +763,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
964,
/**/
963,
/**/