diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-03-17 14:49:09 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-03-17 14:49:09 -0300 |
commit | 5709181243536f0a9f23dc4a8d87fe75cc32537d (patch) | |
tree | f4a3091c402647c9b8f60dceb36bc060d1500006 | |
parent | 67f3ff3dff8c8b4b7d5e6a20e61790730b67a015 (diff) | |
download | rneovim-5709181243536f0a9f23dc4a8d87fe75cc32537d.tar.gz rneovim-5709181243536f0a9f23dc4a8d87fe75cc32537d.tar.bz2 rneovim-5709181243536f0a9f23dc4a8d87fe75cc32537d.zip |
main: Start stdin before sourcing startup scripts
This is required to be compatible with plugins that ask user questions at
startup(eg: vim-addon-local-vimrc)
-rw-r--r-- | src/nvim/main.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index 76fee17726..9479d80f31 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -271,6 +271,13 @@ int main(int argc, char **argv) /* Execute --cmd arguments. */ exe_pre_commands(¶ms); + if (!params.headless && params.input_isatty) { + // Its possible that one of the scripts sourced at startup will prompt the + // user, so start stdin now. TODO(tarruda): This is only for compatibility. + // Startup user prompting should be done in the VimEnter autocmd + input_start_stdin(); + } + /* Source startup scripts. */ source_startup_scripts(¶ms); @@ -351,16 +358,19 @@ int main(int argc, char **argv) if (params.edit_type == EDIT_STDIN && !recoverymode) read_stdin(); - if (!params.headless && (params.output_isatty || params.err_isatty)) { - if (params.input_isatty && (need_wait_return || msg_didany)) { + if (!params.headless) { + if ((params.output_isatty || params.err_isatty) + && (need_wait_return || msg_didany)) { // Since at this point there's no UI instance running yet, error messages - // would have been printed to stdout. Before starting (which can result - // in a alternate screen buffer being shown) we need confirmation that - // the user has seen the messages and that is done with a call to - // wait_return. For that to work, stdin must be openend temporarily. - input_start_stdin(); - wait_return(TRUE); + // would have been printed to stdout. Before starting (which can result in + // a alternate screen buffer being shown) we need confirmation that the + // user has seen the messages and that is done with a call to wait_return. TIME_MSG("waiting for return"); + wait_return(TRUE); + } + + if (params.input_isatty) { + // Stop reading from stdin, the UI module will take over now. input_stop_stdin(); } |