diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-08-06 02:44:15 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-08-06 04:22:45 +0200 |
commit | 3827d5bc713d9ed149bc793f411debb5b89a4eba (patch) | |
tree | fc61484a30532ef89f24c5b60534dccc56408d17 | |
parent | d801ce70c1fb8dd8b3735ca9e06158aaf48203ba (diff) | |
download | rneovim-3827d5bc713d9ed149bc793f411debb5b89a4eba.tar.gz rneovim-3827d5bc713d9ed149bc793f411debb5b89a4eba.tar.bz2 rneovim-3827d5bc713d9ed149bc793f411debb5b89a4eba.zip |
input: skip dialogs if no UI is active
Treat dialogs in the same way as "silent mode" (`nvim -es`).
References #1984
References #3901
-rw-r--r-- | runtime/doc/starting.txt | 7 | ||||
-rw-r--r-- | src/nvim/main.c | 15 | ||||
-rw-r--r-- | src/nvim/message.c | 8 | ||||
-rw-r--r-- | src/nvim/misc1.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test49.vim | 3 | ||||
-rw-r--r-- | test/functional/ui/wildmode_spec.lua | 11 |
6 files changed, 21 insertions, 25 deletions
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 91915406cb..4cfc98d5b6 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -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* diff --git a/src/nvim/main.c b/src/nvim/main.c index 7dcf00c26b..a46c1a58f8 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -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 */ diff --git a/src/nvim/message.c b/src/nvim/message.c index 36f9ca84ed..28c88f5a14 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -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; diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 835b9c7b20..5270687a4d 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -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 */ } diff --git a/src/nvim/testdir/test49.vim b/src/nvim/testdir/test49.vim index a0e170dea4..467abcd9b9 100644 --- a/src/nvim/testdir/test49.vim +++ b/src/nvim/testdir/test49.vim @@ -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 diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 209b0bdfec..41a751c284 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -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 |