mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 21:48:35 +00:00
startup: fix -E/-Es without -u NONE
Before this change, -E/-Es without `-u NONE` reads stdin as Ex commands. It should always read stdin as text (into buffer 1), like this: echo foo | nvim -Es +'%p' foo echo foo | nvim -Es -u NORC +'%p' foo
This commit is contained in:
@@ -301,9 +301,11 @@ int main(int argc, char **argv)
|
|||||||
// Read ex-commands if invoked with "-es".
|
// Read ex-commands if invoked with "-es".
|
||||||
//
|
//
|
||||||
bool reading_tty = !headless_mode
|
bool reading_tty = !headless_mode
|
||||||
|
&& !silent_mode
|
||||||
&& (params.input_isatty || params.output_isatty
|
&& (params.input_isatty || params.output_isatty
|
||||||
|| params.err_isatty);
|
|| params.err_isatty);
|
||||||
bool reading_excmds = !params.input_isatty && silent_mode
|
bool reading_excmds = !params.input_isatty
|
||||||
|
&& silent_mode
|
||||||
&& exmode_active == EXMODE_NORMAL;
|
&& exmode_active == EXMODE_NORMAL;
|
||||||
if (reading_tty || reading_excmds) {
|
if (reading_tty || reading_excmds) {
|
||||||
// One of the startup commands (arguments, sourced scripts or plugins) may
|
// One of the startup commands (arguments, sourced scripts or plugins) may
|
||||||
|
@@ -157,6 +157,14 @@ describe('startup', function()
|
|||||||
eq(inputstr,
|
eq(inputstr,
|
||||||
funcs.system({nvim_prog, '-i', 'NONE', '-Es', '+%print', '-' },
|
funcs.system({nvim_prog, '-i', 'NONE', '-Es', '+%print', '-' },
|
||||||
input))
|
input))
|
||||||
|
-- with `-u NORC`
|
||||||
|
eq('thepartycontinues\n',
|
||||||
|
funcs.system({nvim_prog, '-n', '-u', 'NORC', '-Es', '+.print' },
|
||||||
|
{ 'thepartycontinues', '' }))
|
||||||
|
-- without `-u`
|
||||||
|
eq('thepartycontinues\n',
|
||||||
|
funcs.system({nvim_prog, '-n', '-Es', '+.print' },
|
||||||
|
{ 'thepartycontinues', '' }))
|
||||||
|
|
||||||
--
|
--
|
||||||
-- -es: read stdin as ex-commands
|
-- -es: read stdin as ex-commands
|
||||||
@@ -167,6 +175,14 @@ describe('startup', function()
|
|||||||
eq('line1\nline2\n',
|
eq('line1\nline2\n',
|
||||||
funcs.system({nvim_prog, '-i', 'NONE', '-es', '-' },
|
funcs.system({nvim_prog, '-i', 'NONE', '-es', '-' },
|
||||||
input))
|
input))
|
||||||
|
-- with `-u NORC`
|
||||||
|
eq(' encoding=utf-8\n',
|
||||||
|
funcs.system({nvim_prog, '-n', '-u', 'NORC', '-es' },
|
||||||
|
{ 'set encoding', '' }))
|
||||||
|
-- without `-u`
|
||||||
|
eq(' encoding=utf-8\n',
|
||||||
|
funcs.system({nvim_prog, '-n', '-es' },
|
||||||
|
{ 'set encoding', '' }))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user