diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2025-02-09 22:04:33 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2025-02-10 18:56:11 +0100 |
commit | 4b0e2605eaf90268195029a29f10903dc82729e7 (patch) | |
tree | 76f735084431f5027cdfc90da43370af0f2d2477 /src/nvim/msgpack_rpc/channel.c | |
parent | ad60b3fb4806c0917010bbe97876c22fb57cabcd (diff) | |
download | rneovim-4b0e2605eaf90268195029a29f10903dc82729e7.tar.gz rneovim-4b0e2605eaf90268195029a29f10903dc82729e7.tar.bz2 rneovim-4b0e2605eaf90268195029a29f10903dc82729e7.zip |
feat(ui): UI :detach command
Problem:
Cannot detach the current UI.
Solution:
- Introduce `:detach`.
- Introduce `Channel.detach`.
Co-authored-by: bfredl <bjorn.linse@gmail.com>
Diffstat (limited to 'src/nvim/msgpack_rpc/channel.c')
-rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index e38bc1896d..fa50afd83b 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -224,8 +224,7 @@ static size_t receive_msgpack(RStream *stream, const char *rbuf, size_t c, void if (eof) { channel_close(channel->id, kChannelPartRpc, NULL); char buf[256]; - snprintf(buf, sizeof(buf), "ch %" PRIu64 " was closed by the client", - channel->id); + snprintf(buf, sizeof(buf), "ch %" PRIu64 " was closed by the peer", channel->id); chan_close_with_error(channel, buf, LOGLVL_INF); } @@ -293,7 +292,7 @@ static void parse_msgpack(Channel *channel) Object res = p->result; if (p->result.type != kObjectTypeArray) { - chan_close_with_error(channel, "msgpack-rpc request args has to be an array", LOGLVL_ERR); + chan_close_with_error(channel, "msgpack-rpc request args must be an array", LOGLVL_ERR); return; } Array arg = res.data.array; @@ -487,13 +486,16 @@ void rpc_close(Channel *channel) channel->rpc.closed = true; channel_decref(channel); - if (channel->streamtype == kChannelStreamStdio - || (channel->id == ui_client_channel_id && channel->streamtype != kChannelStreamProc)) { - if (channel->streamtype == kChannelStreamStdio) { - // Avoid hanging when there are no other UIs and a prompt is triggered on exit. - remote_ui_disconnect(channel->id); + 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); + + if (!channel->detach) { + exit_on_closed_chan(0); } - exit_from_channel(0); } } |