diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2025-02-17 02:26:19 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-17 02:26:19 -0800 |
| commit | b360c0608556232c8ddb7ecc9cd26e68584bee76 (patch) | |
| tree | dd9305fdc82de030d3f743008d2922a77757ce49 /src/nvim/msgpack_rpc | |
| parent | bd0a65bc151a7a496e913125f54814f591845e91 (diff) | |
| download | rneovim-b360c0608556232c8ddb7ecc9cd26e68584bee76.tar.gz rneovim-b360c0608556232c8ddb7ecc9cd26e68584bee76.tar.bz2 rneovim-b360c0608556232c8ddb7ecc9cd26e68584bee76.zip | |
refactor(channel): eliminate special case in on_proc_exit() #32485
Problem:
on_proc_exit() has a special-case that assumes that the UI client will
never spawn more than 1 child process.
Solution:
If the Nvim server exits, the stream EOF will trigger `rpc_close()` in
the UI client, so we don't need the special case in `on_proc_exit`.
Pass `Channel.exit_status` from `rpc_close()` so that the correct exit
code is reflected.
Diffstat (limited to 'src/nvim/msgpack_rpc')
| -rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index fa50afd83b..1d24198455 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -486,15 +486,15 @@ void rpc_close(Channel *channel) channel->rpc.closed = true; channel_decref(channel); - if (ui_client_channel_id && channel->id == ui_client_channel_id) { - assert(!channel->detach); // `Channel.detach` is not currently used by the UI client. - exit_on_closed_chan(0); - } else if (channel->streamtype == kChannelStreamStdio) { - // Avoid hanging when there are no other UIs and a prompt is triggered on exit. - remote_ui_disconnect(channel->id); + bool is_ui_client = ui_client_channel_id && channel->id == ui_client_channel_id; + if (is_ui_client || channel->streamtype == kChannelStreamStdio) { + if (!is_ui_client) { + // Avoid hanging when there are no other UIs and a prompt is triggered on exit. + remote_ui_disconnect(channel->id); + } if (!channel->detach) { - exit_on_closed_chan(0); + exit_on_closed_chan(channel->exit_status == -1 ? 0 : channel->exit_status); } } } |