mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
fix(ui): schedule UI detach (#32827)
When a UI detaches it will execute any UILeave events. Autocommands cannot run in a libuv handler because they will in turn poll the event loop, which results in recursive loop execution. So we schedule the callback to detach the UI on the main event queue. We also have to schedule the exit when the RPC channel is closed to ensure it does not run until after `remote_ui_disconnect` has run, otherwise it will hang.
This commit is contained in:
@ -484,6 +484,16 @@ void rpc_close(Channel *channel)
|
||||
}
|
||||
|
||||
channel->rpc.closed = true;
|
||||
|
||||
// Scheduled to avoid running UILeave autocommands in a libuv handler.
|
||||
multiqueue_put(main_loop.fast_events, rpc_close_event, channel);
|
||||
}
|
||||
|
||||
static void rpc_close_event(void **argv)
|
||||
{
|
||||
Channel *channel = (Channel *)argv[0];
|
||||
assert(channel);
|
||||
|
||||
channel_decref(channel);
|
||||
|
||||
bool is_ui_client = ui_client_channel_id && channel->id == ui_client_channel_id;
|
||||
|
Reference in New Issue
Block a user