aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/ui.c
diff options
context:
space:
mode:
authorGeorge Harker <george@george-graphics.co.uk>2023-10-31 20:04:53 -0700
committerGitHub <noreply@github.com>2023-11-01 11:04:53 +0800
commit4e6096a67fe9860994be38bcd155e7c47313205e (patch)
treea4f7ee6792bc27789bd6c052e3d26f2ae51eba72 /src/nvim/api/ui.c
parent746a153bc1a1bc1433a1246fcf454eeb058b9de1 (diff)
downloadrneovim-4e6096a67fe9860994be38bcd155e7c47313205e.tar.gz
rneovim-4e6096a67fe9860994be38bcd155e7c47313205e.tar.bz2
rneovim-4e6096a67fe9860994be38bcd155e7c47313205e.zip
feat(server): allow embed with listen (#25709)
connection from any channel or stdio will unblock remote_ui_wait_for_attach. Wait on stdio only if only —embed specified, if both —embed and —listen then wait on any channel.
Diffstat (limited to 'src/nvim/api/ui.c')
-rw-r--r--src/nvim/api/ui.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index e0b5e6ea57..b508a3ee94 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -126,18 +126,24 @@ void remote_ui_disconnect(uint64_t channel_id)
xfree(ui);
}
-/// Wait until ui has connected on stdio channel.
-void remote_ui_wait_for_attach(void)
+/// Wait until ui has connected on stdio channel if only_stdio
+/// is true, otherwise any channel.
+void remote_ui_wait_for_attach(bool only_stdio)
{
- Channel *channel = find_channel(CHAN_STDIO);
- if (!channel) {
- // this function should only be called in --embed mode, stdio channel
- // can be assumed.
- abort();
- }
+ if (only_stdio) {
+ Channel *channel = find_channel(CHAN_STDIO);
+ if (!channel) {
+ // this function should only be called in --embed mode, stdio channel
+ // can be assumed.
+ abort();
+ }
- LOOP_PROCESS_EVENTS_UNTIL(&main_loop, channel->events, -1,
- map_has(uint64_t, &connected_uis, CHAN_STDIO));
+ LOOP_PROCESS_EVENTS_UNTIL(&main_loop, channel->events, -1,
+ map_has(uint64_t, &connected_uis, CHAN_STDIO));
+ } else {
+ LOOP_PROCESS_EVENTS_UNTIL(&main_loop, main_loop.events, -1,
+ ui_active());
+ }
}
/// Activates UI events on the channel.