From 7b0123dd6a06a032516cce66d82c064b1d942013 Mon Sep 17 00:00:00 2001 From: shafouz <38974831+shafouz@users.noreply.github.com> Date: Sun, 13 Aug 2023 02:14:08 -0400 Subject: [PATCH] feat(remote): avoid --remote-ui infinite loop (#24465) --- src/nvim/main.c | 5 +++++ test/functional/core/startup_spec.lua | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/nvim/main.c b/src/nvim/main.c index 377b804661..d9ca82784f 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -921,6 +921,11 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr, os_errmsg(connect_error); os_errmsg("\n"); os_exit(1); + } else if (strequal(server_addr, os_getenv("NVIM"))) { + os_errmsg("Cannot attach UI of :terminal child to its parent. "); + os_errmsg("(Unset $NVIM to skip this check)"); + os_errmsg("\n"); + os_exit(1); } ui_client_channel_id = chan; diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index fb30ddebb9..94ec3d4907 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -41,6 +41,19 @@ describe('startup', function() ok(string.find(alter_slashes(meths.get_option_value('runtimepath', {})), funcs.stdpath('config'), 1, true) == nil) end) + it('prevents remote UI infinite loop', function() + clear() + local screen + screen = Screen.new(84, 3) + screen:attach() + funcs.termopen({ nvim_prog, '-u', 'NONE', '--server', eval('v:servername'), '--remote-ui' }) + screen:expect([[ + ^Cannot attach UI of :terminal child to its parent. (Unset $NVIM to skip this check) | + | + | + ]]) + end) + it('--startuptime', function() local testfile = 'Xtest_startuptime' finally(function()