mirror of
https://github.com/neovim/neovim
synced 2025-07-17 09:41:46 +00:00
fix(:print): don't use schar_from_ascii() for illegal byte (#34046)
(cherry picked from commit 6af1b7e5e8
)
This commit is contained in:
committed by
github-actions[bot]
parent
12ae7aa846
commit
a242902430
@ -2011,6 +2011,11 @@ void msg_prt_line(const char *s, bool list)
|
|||||||
} else {
|
} else {
|
||||||
hl_id = 0;
|
hl_id = 0;
|
||||||
int c = (uint8_t)(*s++);
|
int c = (uint8_t)(*s++);
|
||||||
|
if (c >= 0x80) { // Illegal byte
|
||||||
|
col += utf_char2cells(c);
|
||||||
|
msg_putchar(c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sc_extra = NUL;
|
sc_extra = NUL;
|
||||||
sc_final = NUL;
|
sc_final = NUL;
|
||||||
if (list) {
|
if (list) {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
local t = require('test.testutil')
|
local t = require('test.testutil')
|
||||||
local n = require('test.functional.testnvim')()
|
local n = require('test.functional.testnvim')()
|
||||||
|
local Screen = require('test.functional.ui.screen')
|
||||||
|
|
||||||
local clear, eq, command, fn = n.clear, t.eq, n.command, n.fn
|
local clear, eq, command, fn = n.clear, t.eq, n.command, n.fn
|
||||||
|
local assert_alive = n.assert_alive
|
||||||
|
|
||||||
describe(':z^', function()
|
describe(':z^', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
@ -11,3 +13,20 @@ describe(':z^', function()
|
|||||||
eq(1, fn.line('.'))
|
eq(1, fn.line('.'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe(':print', function()
|
||||||
|
before_each(clear)
|
||||||
|
|
||||||
|
it('does not crash when printing 0xFF byte #34044', function()
|
||||||
|
local screen = Screen.new()
|
||||||
|
-- Needs raw 0xFF byte, not 0xFF char
|
||||||
|
command('call setline(1, "foo\\xFFbar")')
|
||||||
|
command('%print')
|
||||||
|
screen:expect([[
|
||||||
|
^foo{18:<ff>}bar |
|
||||||
|
{1:~ }|*12
|
||||||
|
fooÿbar |
|
||||||
|
]])
|
||||||
|
assert_alive()
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
Reference in New Issue
Block a user