return 4;
// If the char is ASCII it must be an overlong sequence.
if (c < 0x80)
- return char2cells(c);
+ return vim_isprintc(c) ? char2cells(c) : 4;
return utf_char2cells(c);
}
return 1;
return 4;
// If the char is ASCII it must be an overlong sequence.
if (c < 0x80)
- return char2cells(c);
+ return vim_isprintc(c) ? char2cells(c) : 4;
return utf_char2cells(c);
}
return 1;
bwipe!
endfunc
+" The cell count of an overlong encoded character must match what is drawn.
+func Test_overlong_utf8_cells()
+ call assert_equal(4, strdisplaywidth("\xc0\x81")) " <01>
+ call assert_equal(4, strdisplaywidth("\xe0\x80\x81")) " <01>, three bytes
+ call assert_equal(4, strdisplaywidth("\xc1\xbf")) " <7f>
+ call assert_equal(4, strdisplaywidth("\xc0\x89")) " <09>, not a Tab
+
+ new
+ call setline(1, "\xc1\x81\xc0\x81\xc0\x80")
+ call assert_equal('A<01><00>', ScreenLines(1, 9)[0])
+ normal! $
+ call assert_equal(5, col('.'))
+ call assert_equal([6, 9], virtcol('.', v:true))
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab