From b4cd55df15385e33a89f03df7ec4aa4b338e7178 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 15 Jan 2026 09:00:55 +0800 Subject: [PATCH] refactor(event/stream.c): fix confusing indent (#37398) (cherry picked from commit 896968cad1ea853521ea71a9fef854337a21843c) --- src/nvim/event/stream.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c index 13615307ab..6fa843600a 100644 --- a/src/nvim/event/stream.c +++ b/src/nvim/event/stream.c @@ -46,7 +46,7 @@ void stream_init(Loop *loop, Stream *stream, int fd, uv_stream_t *uvstream) FUNC_ATTR_NONNULL_ARG(2) { // The underlying stream is either a file or an existing uv stream. - assert(uvstream == NULL ? fd >= 0 : fd < 0); + assert(uvstream == NULL ? fd >= 0 && loop != NULL : fd < 0 && loop == NULL); stream->uvstream = uvstream; if (fd >= 0) { @@ -59,26 +59,22 @@ void stream_init(Loop *loop, Stream *stream, int fd, uv_stream_t *uvstream) // processed between reads. uv_idle_init(&loop->uv, &stream->uv.idle); stream->uv.idle.data = stream; +#ifdef MSWIN + } else if (type == UV_TTY) { + uv_tty_init(&loop->uv, &stream->uv.tty, fd, 0); + uv_tty_set_mode(&stream->uv.tty, UV_TTY_MODE_RAW); + DWORD dwMode; + if (GetConsoleMode(stream->uv.tty.handle, &dwMode)) { + dwMode |= ENABLE_VIRTUAL_TERMINAL_INPUT; + SetConsoleMode(stream->uv.tty.handle, dwMode); + } + stream->uvstream = (uv_stream_t *)&stream->uv.tty; +#endif } else { assert(type == UV_NAMED_PIPE || type == UV_TTY); -#ifdef MSWIN - if (type == UV_TTY) { - uv_tty_init(&loop->uv, &stream->uv.tty, fd, 0); - uv_tty_set_mode(&stream->uv.tty, UV_TTY_MODE_RAW); - DWORD dwMode; - if (GetConsoleMode(stream->uv.tty.handle, &dwMode)) { - dwMode |= ENABLE_VIRTUAL_TERMINAL_INPUT; - SetConsoleMode(stream->uv.tty.handle, dwMode); - } - stream->uvstream = (uv_stream_t *)&stream->uv.tty; - } else { -#endif uv_pipe_init(&loop->uv, &stream->uv.pipe, 0); uv_pipe_open(&stream->uv.pipe, fd); stream->uvstream = (uv_stream_t *)&stream->uv.pipe; -#ifdef MSWIN - } -#endif } }