mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
Merge pull request #22244 from zeertzjq/tui-eof
fix(tui): exit on input eof
This commit is contained in:
@@ -470,11 +470,6 @@ static InbufPollResult inbuf_poll(int ms, MultiQueue *events)
|
|||||||
return input_eof ? kInputEof : kInputNone;
|
return input_eof ? kInputEof : kInputNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
void input_done(void)
|
|
||||||
{
|
|
||||||
input_eof = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool input_available(void)
|
bool input_available(void)
|
||||||
{
|
{
|
||||||
return rbuffer_size(input_buffer) != 0;
|
return rbuffer_size(input_buffer) != 0;
|
||||||
@@ -483,7 +478,7 @@ bool input_available(void)
|
|||||||
static void input_read_cb(Stream *stream, RBuffer *buf, size_t c, void *data, bool at_eof)
|
static void input_read_cb(Stream *stream, RBuffer *buf, size_t c, void *data, bool at_eof)
|
||||||
{
|
{
|
||||||
if (at_eof) {
|
if (at_eof) {
|
||||||
input_done();
|
input_eof = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(rbuffer_space(input_buffer) >= rbuffer_size(buf));
|
assert(rbuffer_space(input_buffer) >= rbuffer_size(buf));
|
||||||
|
@@ -185,8 +185,9 @@ void tinput_stop(TermInput *input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void tinput_done_event(void **argv)
|
static void tinput_done_event(void **argv)
|
||||||
|
FUNC_ATTR_NORETURN
|
||||||
{
|
{
|
||||||
input_done();
|
os_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tinput_wait_enqueue(void **argv)
|
static void tinput_wait_enqueue(void **argv)
|
||||||
|
@@ -167,7 +167,7 @@ static bool cursor_style_enabled = false;
|
|||||||
# include "tui/tui.c.generated.h"
|
# include "tui/tui.c.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TUIData *tui_start(int *width, int *height, char **term)
|
void tui_start(TUIData **tui_p, int *width, int *height, char **term)
|
||||||
{
|
{
|
||||||
TUIData *tui = xcalloc(1, sizeof(TUIData));
|
TUIData *tui = xcalloc(1, sizeof(TUIData));
|
||||||
tui->is_starting = true;
|
tui->is_starting = true;
|
||||||
@@ -190,11 +190,11 @@ TUIData *tui_start(int *width, int *height, char **term)
|
|||||||
uv_timer_start(&tui->startup_delay_timer, after_startup_cb,
|
uv_timer_start(&tui->startup_delay_timer, after_startup_cb,
|
||||||
100, 0);
|
100, 0);
|
||||||
|
|
||||||
|
*tui_p = tui;
|
||||||
loop_poll_events(&main_loop, 1);
|
loop_poll_events(&main_loop, 1);
|
||||||
*width = tui->width;
|
*width = tui->width;
|
||||||
*height = tui->height;
|
*height = tui->height;
|
||||||
*term = tui->term;
|
*term = tui->term;
|
||||||
return tui;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tui_enable_extkeys(TUIData *tui)
|
void tui_enable_extkeys(TUIData *tui)
|
||||||
|
@@ -113,7 +113,7 @@ void ui_client_run(bool remote_ui)
|
|||||||
ui_client_is_remote = remote_ui;
|
ui_client_is_remote = remote_ui;
|
||||||
int width, height;
|
int width, height;
|
||||||
char *term;
|
char *term;
|
||||||
tui = tui_start(&width, &height, &term);
|
tui_start(&tui, &width, &height, &term);
|
||||||
|
|
||||||
ui_client_attach(width, height, term);
|
ui_client_attach(width, height, term);
|
||||||
|
|
||||||
|
@@ -2365,18 +2365,18 @@ describe("TUI as a client", function()
|
|||||||
|
|
||||||
set_session(client_super)
|
set_session(client_super)
|
||||||
local screen_client = thelpers.screen_setup(0,
|
local screen_client = thelpers.screen_setup(0,
|
||||||
string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--server", "%s", "--remote-ui"]]=],
|
string.format([=[["%s", "--server", "%s", "--remote-ui"]]=],
|
||||||
nvim_prog, server_pipe))
|
nvim_prog, server_pipe))
|
||||||
|
|
||||||
screen_client:expect{grid=[[
|
screen_client:expect{grid=[[
|
||||||
Hello, Worl{1:d} |
|
Hello, Worl{1:d} |
|
||||||
{4:~ }|
|
{4:~ }|
|
||||||
{4:~ }|
|
{4:~ }|
|
||||||
{4:~ }|
|
{4:~ }|
|
||||||
{5:[No Name] [+] }|
|
{5:[No Name] [+] }|
|
||||||
|
|
|
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]]}
|
]]}
|
||||||
|
|
||||||
feed_data(":q!\n")
|
feed_data(":q!\n")
|
||||||
|
|
||||||
@@ -2394,7 +2394,7 @@ describe("TUI as a client", function()
|
|||||||
|
|
||||||
set_session(client_super)
|
set_session(client_super)
|
||||||
local screen = thelpers.screen_setup(0,
|
local screen = thelpers.screen_setup(0,
|
||||||
string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--server", "%s", "--remote-ui"]]=],
|
string.format([=[["%s", "--server", "%s", "--remote-ui"]]=],
|
||||||
nvim_prog, server_pipe))
|
nvim_prog, server_pipe))
|
||||||
|
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
@@ -2412,15 +2412,19 @@ describe("TUI as a client", function()
|
|||||||
exec_lua([[vim.loop.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
|
exec_lua([[vim.loop.kill(vim.fn.jobpid(vim.bo.channel), 'sigterm')]])
|
||||||
screen:expect({any = '%[Process exited 1%]'})
|
screen:expect({any = '%[Process exited 1%]'})
|
||||||
|
|
||||||
|
eq(0, meths.get_vvar('shell_error'))
|
||||||
|
-- exits on input eof #22244
|
||||||
|
funcs.system({nvim_prog, '--server', server_pipe, '--remote-ui'})
|
||||||
|
eq(1, meths.get_vvar('shell_error'))
|
||||||
|
|
||||||
client_super:close()
|
client_super:close()
|
||||||
server:close()
|
server:close()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
it("throws error when no server exists", function()
|
it("throws error when no server exists", function()
|
||||||
clear()
|
clear()
|
||||||
local screen = thelpers.screen_setup(0,
|
local screen = thelpers.screen_setup(0,
|
||||||
string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--server", "127.0.0.1:2436546", "--remote-ui"]]=],
|
string.format([=[["%s", "--server", "127.0.0.1:2436546", "--remote-ui"]]=],
|
||||||
nvim_prog), 60)
|
nvim_prog), 60)
|
||||||
|
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@@ -2467,7 +2471,7 @@ describe("TUI as a client", function()
|
|||||||
|
|
||||||
set_session(client_super)
|
set_session(client_super)
|
||||||
local screen_client = thelpers.screen_setup(0,
|
local screen_client = thelpers.screen_setup(0,
|
||||||
string.format([=[["%s", "-u", "NONE", "-i", "NONE", "--server", "%s", "--remote-ui"]]=],
|
string.format([=[["%s", "--server", "%s", "--remote-ui"]]=],
|
||||||
nvim_prog, server_pipe))
|
nvim_prog, server_pipe))
|
||||||
|
|
||||||
screen_client:expect{grid=[[
|
screen_client:expect{grid=[[
|
||||||
|
Reference in New Issue
Block a user