mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
cleanup, test interactive -E
This commit is contained in:
parent
1f300e08b8
commit
d8c7ff1335
@ -300,15 +300,16 @@ int main(int argc, char **argv)
|
||||
// Read user-input if any TTY is connected.
|
||||
// Read ex-commands if invoked with "-es".
|
||||
//
|
||||
bool reading_input = !headless_mode
|
||||
&& (params.input_isatty || params.output_isatty
|
||||
|| params.err_isatty);
|
||||
bool reading_excmds = exmode_active == EXMODE_NORMAL;
|
||||
if (reading_input || reading_excmds) {
|
||||
bool reading_tty = !headless_mode
|
||||
&& (params.input_isatty || params.output_isatty
|
||||
|| params.err_isatty);
|
||||
bool reading_excmds = !params.input_isatty && silent_mode
|
||||
&& exmode_active == EXMODE_NORMAL;
|
||||
if (reading_tty || reading_excmds) {
|
||||
// One of the startup commands (arguments, sourced scripts or plugins) may
|
||||
// prompt the user, so start reading from a tty now.
|
||||
int fd = STDIN_FILENO;
|
||||
if (!reading_excmds
|
||||
if (!silent_mode
|
||||
&& (!params.input_isatty || params.edit_type == EDIT_STDIN)) {
|
||||
// Use stderr or stdout since stdin is being used to read commands.
|
||||
fd = params.err_isatty ? fileno(stderr) : fileno(stdout);
|
||||
@ -435,7 +436,7 @@ int main(int argc, char **argv)
|
||||
read_stdin();
|
||||
}
|
||||
|
||||
if (reading_input && (need_wait_return || msg_didany)) {
|
||||
if (reading_tty && (need_wait_return || msg_didany)) {
|
||||
// Because there's no UI yet, error messages would have been printed to
|
||||
// stdout. Before starting we need confirmation that the user has seen the
|
||||
// messages and that is done with a call to wait_return.
|
||||
@ -444,7 +445,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!headless_mode && !silent_mode) {
|
||||
input_stop(); // Stop reading from input stream. UI will take over.
|
||||
input_stop(); // Stop reading input, let the UI take over.
|
||||
ui_builtin_start();
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ typedef enum {
|
||||
kInputEof
|
||||
} InbufPollResult;
|
||||
|
||||
static Stream read_stream = {.closed = true};
|
||||
static Stream read_stream = { .closed = true }; // Input before UI starts.
|
||||
static RBuffer *input_buffer = NULL;
|
||||
static bool input_eof = false;
|
||||
static int global_fd = -1;
|
||||
@ -50,7 +50,7 @@ void input_init(void)
|
||||
input_buffer = rbuffer_new(INPUT_BUFFER_SIZE + MAX_KEY_CODE_LEN);
|
||||
}
|
||||
|
||||
/// This is the global stream of user-input (or Ex-commands for "-es").
|
||||
/// Global TTY (or pipe for "-es") input stream, before UI starts.
|
||||
int input_global_fd(void)
|
||||
{
|
||||
return global_fd;
|
||||
@ -109,7 +109,7 @@ int os_inchar(uint8_t *buf, int maxlen, int ms, int tb_change_cnt)
|
||||
} else {
|
||||
if ((result = inbuf_poll((int)p_ut)) == kInputNone) {
|
||||
if (read_stream.closed && silent_mode) {
|
||||
// Drained input and eventloop: exit silent/batch-mode (-es/-Es).
|
||||
// Drained eventloop & initial input; exit silent/batch-mode (-es/-Es).
|
||||
read_error_exit();
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ local Screen = require('test.functional.ui.screen')
|
||||
local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
local eq = helpers.eq
|
||||
local feed = helpers.feed
|
||||
local funcs = helpers.funcs
|
||||
local nvim_prog = helpers.nvim_prog
|
||||
local nvim_set = helpers.nvim_set
|
||||
@ -121,6 +122,18 @@ describe('startup', function()
|
||||
{ 'ohyeah', '' }))
|
||||
end)
|
||||
|
||||
it('-e/-E interactive #7679', function()
|
||||
clear('-E')
|
||||
local screen = Screen.new(25, 3)
|
||||
screen:attach()
|
||||
feed("put ='from -E'<CR>")
|
||||
screen:expect([[
|
||||
|
|
||||
from -E |
|
||||
:^ |
|
||||
]])
|
||||
end)
|
||||
|
||||
it('stdin with -es/-Es #7679', function()
|
||||
local input = { 'append', 'line1', 'line2', '.', '%print', '' }
|
||||
local inputstr = table.concat(input, '\n')
|
||||
|
@ -316,6 +316,14 @@ local function retry(max, max_ms, fn)
|
||||
end
|
||||
end
|
||||
|
||||
-- Starts a new global Nvim session.
|
||||
-- Parameters are interpreted as startup args, OR a map with these keys:
|
||||
-- args: Merged with the default `nvim_argv` set.
|
||||
-- env : Defines the environment of the new session.
|
||||
--
|
||||
-- Example:
|
||||
-- clear('-e')
|
||||
-- clear({args={'-e'}, env={TERM=term}})
|
||||
local function clear(...)
|
||||
local args = {unpack(nvim_argv)}
|
||||
local new_args
|
||||
|
Loading…
Reference in New Issue
Block a user