mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(rpc): ignore redraw events when not in UI client (#21892)
Otherwise it will crash.
This commit is contained in:
@@ -247,10 +247,12 @@ static void parse_msgpack(Channel *channel)
|
|||||||
Unpacker *p = channel->rpc.unpacker;
|
Unpacker *p = channel->rpc.unpacker;
|
||||||
while (unpacker_advance(p)) {
|
while (unpacker_advance(p)) {
|
||||||
if (p->type == kMessageTypeRedrawEvent) {
|
if (p->type == kMessageTypeRedrawEvent) {
|
||||||
if (p->grid_line_event) {
|
if (ui_client_channel_id) {
|
||||||
ui_client_event_raw_line(p->grid_line_event);
|
if (p->grid_line_event) {
|
||||||
} else if (p->ui_handler.fn != NULL && p->result.type == kObjectTypeArray) {
|
ui_client_event_raw_line(p->grid_line_event);
|
||||||
p->ui_handler.fn(p->result.data.array);
|
} else if (p->ui_handler.fn != NULL && p->result.type == kObjectTypeArray) {
|
||||||
|
p->ui_handler.fn(p->result.data.array);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
arena_mem_free(arena_finish(&p->arena));
|
arena_mem_free(arena_finish(&p->arena));
|
||||||
} else if (p->type == kMessageTypeResponse) {
|
} else if (p->type == kMessageTypeResponse) {
|
||||||
|
@@ -337,6 +337,21 @@ describe('server -> client', function()
|
|||||||
eq('localhost:', string.sub(address,1,10))
|
eq('localhost:', string.sub(address,1,10))
|
||||||
connect_test(server, 'tcp', address)
|
connect_test(server, 'tcp', address)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('does not crash on receiving UI events', function()
|
||||||
|
local server = spawn(nvim_argv)
|
||||||
|
set_session(server)
|
||||||
|
local address = funcs.serverlist()[1]
|
||||||
|
local client = spawn(nvim_argv, false, nil, true)
|
||||||
|
set_session(client)
|
||||||
|
|
||||||
|
local id = funcs.sockconnect('pipe', address, {rpc=true})
|
||||||
|
funcs.rpcrequest(id, 'nvim_ui_attach', 80, 24, {})
|
||||||
|
assert_alive()
|
||||||
|
|
||||||
|
server:close()
|
||||||
|
client:close()
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('connecting to its own pipe address', function()
|
describe('connecting to its own pipe address', function()
|
||||||
|
Reference in New Issue
Block a user