mirror of
https://github.com/neovim/neovim.git
synced 2026-08-28 18:11:47 +00:00
fix(tui): avoid using uv_pipe_t as uv_tty_t (#37479)
Check tui->out_isatty before accessing tui->output_handle.tty.
This commit is contained in:
@@ -1389,7 +1389,7 @@ void tui_mode_change(TUIData *tui, String mode, Integer mode_idx)
|
|||||||
// If stdin is not a TTY, the LHS of pipe may change the state of the TTY
|
// If stdin is not a TTY, the LHS of pipe may change the state of the TTY
|
||||||
// after calling uv_tty_set_mode. So, set the mode of the TTY again here.
|
// after calling uv_tty_set_mode. So, set the mode of the TTY again here.
|
||||||
// #13073
|
// #13073
|
||||||
if (tui->is_starting && !stdin_isatty) {
|
if (tui->out_isatty && tui->is_starting && !stdin_isatty) {
|
||||||
int ret = uv_tty_set_mode(&tui->output_handle.tty, UV_TTY_MODE_NORMAL);
|
int ret = uv_tty_set_mode(&tui->output_handle.tty, UV_TTY_MODE_NORMAL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ELOG("uv_tty_set_mode failed: %s", uv_strerror(ret));
|
ELOG("uv_tty_set_mode failed: %s", uv_strerror(ret));
|
||||||
|
|||||||
@@ -4023,7 +4023,7 @@ describe('TUI client', function()
|
|||||||
screen_client:expect({ any = vim.pesc('[Process exited 0]') })
|
screen_client:expect({ any = vim.pesc('[Process exited 0]') })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function start_headless_server_and_client()
|
local function start_headless_server_and_client(use_testlog)
|
||||||
local server = n.new_session(false, {
|
local server = n.new_session(false, {
|
||||||
args_rm = { '--cmd' },
|
args_rm = { '--cmd' },
|
||||||
args = {
|
args = {
|
||||||
@@ -4033,7 +4033,8 @@ describe('TUI client', function()
|
|||||||
nvim_set .. ' notermguicolors background=dark',
|
nvim_set .. ' notermguicolors background=dark',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
local client_super = n.new_session(true, { env = { NVIM_LOG_FILE = testlog } })
|
local client_super =
|
||||||
|
n.new_session(true, use_testlog and { env = { NVIM_LOG_FILE = testlog } } or {})
|
||||||
finally(function()
|
finally(function()
|
||||||
client_super:close()
|
client_super:close()
|
||||||
server:close()
|
server:close()
|
||||||
@@ -4062,7 +4063,7 @@ describe('TUI client', function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
it('connects to remote instance (--headless)', function()
|
it('connects to remote instance (--headless)', function()
|
||||||
local server, server_pipe, screen_client = start_headless_server_and_client()
|
local server, server_pipe, screen_client = start_headless_server_and_client(false)
|
||||||
|
|
||||||
-- No heap-use-after-free when receiving UI events after deadly signal #22184
|
-- No heap-use-after-free when receiving UI events after deadly signal #22184
|
||||||
server:request('nvim_input', ('a'):rep(1000))
|
server:request('nvim_input', ('a'):rep(1000))
|
||||||
@@ -4077,6 +4078,7 @@ describe('TUI client', function()
|
|||||||
|
|
||||||
eq(0, api.nvim_get_vvar('shell_error'))
|
eq(0, api.nvim_get_vvar('shell_error'))
|
||||||
-- exits on input eof #22244
|
-- exits on input eof #22244
|
||||||
|
-- Use system() without input so that stdin is closed.
|
||||||
fn.system({ nvim_prog, '--remote-ui', '--server', server_pipe })
|
fn.system({ nvim_prog, '--remote-ui', '--server', server_pipe })
|
||||||
eq(1, api.nvim_get_vvar('shell_error'))
|
eq(1, api.nvim_get_vvar('shell_error'))
|
||||||
|
|
||||||
@@ -4095,16 +4097,10 @@ describe('TUI client', function()
|
|||||||
|
|
||||||
feed_data(':echo "GUI Running: " .. has("gui_running")\013')
|
feed_data(':echo "GUI Running: " .. has("gui_running")\013')
|
||||||
screen_client:expect({ any = 'GUI Running: 0' })
|
screen_client:expect({ any = 'GUI Running: 0' })
|
||||||
|
|
||||||
if is_os('mac') then
|
|
||||||
-- this might either be "Unknown system error %-102" or
|
|
||||||
-- "inappropriate ioctl for device" depending on the phase of the moon
|
|
||||||
assert_log('uv_tty_set_mode failed', testlog)
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it(':restart works when connecting to remote instance (--headless)', function()
|
it(':restart works when connecting to remote instance (--headless)', function()
|
||||||
local _, server_pipe, screen_client = start_headless_server_and_client()
|
local _, server_pipe, screen_client = start_headless_server_and_client(false)
|
||||||
|
|
||||||
-- Run :restart on the client.
|
-- Run :restart on the client.
|
||||||
-- The client should start a new server while the original server should exit.
|
-- The client should start a new server while the original server should exit.
|
||||||
@@ -4127,7 +4123,7 @@ describe('TUI client', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not crash or hang with a very long title', function()
|
it('does not crash or hang with a very long title', function()
|
||||||
local server, _, screen_client = start_headless_server_and_client()
|
local server, _, screen_client = start_headless_server_and_client(true)
|
||||||
|
|
||||||
local server_exec_lua = tt.make_lua_executor(server)
|
local server_exec_lua = tt.make_lua_executor(server)
|
||||||
if not server_exec_lua('return pcall(require, "ffi")') then
|
if not server_exec_lua('return pcall(require, "ffi")') then
|
||||||
@@ -4165,7 +4161,7 @@ describe('TUI client', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('nvim_ui_send works with remote client #36317', function()
|
it('nvim_ui_send works with remote client #36317', function()
|
||||||
local server, _, _ = start_headless_server_and_client()
|
local server, _, _ = start_headless_server_and_client(false)
|
||||||
server:request('nvim_ui_send', '\027]2;TEST_TITLE\027\\')
|
server:request('nvim_ui_send', '\027]2;TEST_TITLE\027\\')
|
||||||
retry(nil, nil, function()
|
retry(nil, nil, function()
|
||||||
eq('TEST_TITLE', api.nvim_buf_get_var(0, 'term_title'))
|
eq('TEST_TITLE', api.nvim_buf_get_var(0, 'term_title'))
|
||||||
|
|||||||
Reference in New Issue
Block a user