input: skip dialogs if no UI is active

Treat dialogs in the same way as "silent mode" (`nvim -es`).

References #1984
References #3901
This commit is contained in:
Justin M. Keyes
2017-08-06 02:44:15 +02:00
parent d801ce70c1
commit 3827d5bc71
6 changed files with 21 additions and 25 deletions

View File

@@ -53,7 +53,7 @@ filename One or more file names. The first one will be the current
< Starting in Ex mode: >
nvim -e -
nvim -E
< Start editing in silent mode. See |-s-ex|.
< Start editing in |silent-mode|.
*-t* *-tag*
-t {tag} A tag. "tag" is looked up in the tags file, the associated
@@ -200,7 +200,7 @@ argument.
*-E*
-E Start Vim in improved Ex mode |gQ|.
*-s-ex*
*-s-ex* *silent-mode*
-s Silent or batch mode. Only when "-s" is preceded by the "-e"
argument. Otherwise see |-s|, which does take an argument
while this use of "-s" doesn't. To be used when Vim is used
@@ -221,7 +221,7 @@ argument.
Initializations are skipped (except the ones given with the
"-u" argument).
Example: >
vim -e -s < thefilter thefile
vim -es < thefilter thefile
<
*-b*
-b Binary mode. File I/O will only recognize <NL> to separate
@@ -351,6 +351,7 @@ argument.
*--headless*
--headless Do not start the built-in UI.
See also |silent-mode|, which does start a (limited) UI.
==============================================================================
2. Initialization *initialization* *startup*

View File

@@ -98,10 +98,8 @@ typedef struct {
bool input_isatty; // stdin is a terminal
bool output_isatty; // stdout is a terminal
bool err_isatty; // stderr is a terminal
bool headless; // Dont try to start an user interface
// or read/write to stdio(unless
// embedding)
int no_swap_file; /* "-n" argument used */
bool headless; // Do not start the builtin UI.
int no_swap_file; // "-n" argument used
int use_debug_break_level;
int window_count; /* number of windows to use */
int window_layout; /* 0, WIN_HOR, WIN_VER or WIN_TABS */
@@ -932,10 +930,11 @@ static void command_line_scan(mparm_T *parmp)
break;
case 's':
if (exmode_active) /* "-s" silent (batch) mode */
silent_mode = TRUE;
else /* "-s {scriptin}" read from script file */
want_argument = TRUE;
if (exmode_active) { // "-es" silent (batch) mode
silent_mode = true;
} else { // "-s {scriptin}" read from script file
want_argument = true;
}
break;
case 't': /* "-t {tag}" or "-t{tag}" jump to tag */

View File

@@ -2722,9 +2722,11 @@ do_dialog (
int c;
int i;
/* Don't output anything in silent mode ("ex -s") */
if (silent_mode)
return dfltbutton; /* return default option */
if (silent_mode // No dialogs in silent mode ("ex -s")
|| !ui_active() // Without a UI Nvim waits for input forever.
) {
return dfltbutton; // return default option
}
oldState = State;

View File

@@ -2203,7 +2203,7 @@ change_warning (
set_vim_var_string(VV_WARNINGMSG, _(w_readonly), -1);
msg_clr_eos();
(void)msg_end();
if (msg_silent == 0 && !silent_mode) {
if (msg_silent == 0 && !silent_mode && ui_active()) {
ui_flush();
os_delay(1000L, true); /* give the user time to think about it */
}

View File

@@ -481,12 +481,9 @@ function! ExtraVim(...)
bwipeout
let g:Xpath = g:Xpath + sum
" FIXME(nvim): delete() of a file used by a subprocess hangs TSAN build on travis CI.
if !empty($TRAVIS)
" Delete the extra script and the resultfile.
call delete(extra_script)
call delete(resultfile)
endif
" Switch back to the buffer that was active when this function was entered.
exec "buffer" current_buffnr

View File

@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, command = helpers.clear, helpers.feed, helpers.command
local iswin, set_shell_powershell = helpers.iswin, helpers.set_shell_powershell
local iswin = helpers.iswin
local funcs = helpers.funcs
local eq = helpers.eq
local eval = helpers.eval
@@ -124,12 +124,9 @@ describe("'wildmenu'", function()
-- must wait the full timeout. So make it reasonable.
screen.timeout = 1000
if iswin() then
set_shell_powershell()
else
command('set shell=sh')
if not iswin() then
command('set shell=sh') -- Need a predictable "$" prompt.
end
command('set laststatus=0')
command('vsplit')
command('term')
@@ -137,7 +134,7 @@ describe("'wildmenu'", function()
-- Check for a shell prompt to verify that the terminal loaded.
retry(nil, nil, function()
if iswin() then
eq('PS', eval("matchstr(join(getline(1, '$')), 'PS')"))
eq('Microsoft', eval("matchstr(join(getline(1, '$')), 'Microsoft')"))
else
eq('$', eval([[matchstr(getline(1), '\$')]]))
end