Skip to content

Commit

Permalink
Use input() to make sure deprecation messages get seen
Browse files Browse the repository at this point in the history
Quoting the rationale from what I wrote in a similar instance in the
Ferret plug-in:

" Use `input()` to show error output to user. Ideally, we would do this in a way
" that didn't require user interaction, but this is the only reliable mechanism
" that works for all cases. Alternatives considered:
"
" (1) Using `:echomsg`
"
"     When not using vim-dispatch, the screen is getting cleared before the
"     user sees it, even with a pre-emptive `:redraw!` beforehand. Note that
"     we can get the message to linger on the screen by making it multi-line and
"     forcing Vim to show a prompt (see `:h hit-enter-prompt`), but this is not
"     reliable because the number of lines required to force the prompt will
"     vary by system, depending on the value of `'cmdheight'`.
"
"     When using vim-dispatch, anything we output ends up getting swallowed
"     before the user sees it, because something it is doing is clearing the
"     screen. This is true no matter how many lines we output.
"
" (2) Writing back into the quickfix/location list
"
"     This interacts poorly with vim-dispatch. If we write back an error message
"     and then call `:copen 1`, vim-dispatch ends up closing the listing before
"     the user sees it.
"
" (3) Using `:echoerr`
"
"     This works, but presents to the user as an exception (see `:h :echoerr`).
  • Loading branch information
wincent committed Dec 26, 2015
1 parent afc9442 commit 47d8a9f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion autoload/commandt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ let s:deprecated = {
for [old, new] in items(s:deprecated)
execute
\ "function! " . old . "(...) abort \n" .
\ " echoerr \"" . old . "() is deprecated: use " . new . "() instead\"\n" .
\ " call inputsave()\n" .
\ " echohl ErroMsg\n" .
\ " let l:message = \"" . old . "() is deprecated: use " . new . "() instead\"\n" .
\ " call input(l:message . ' [press ENTER to continue]')\n" .
\ " echohl NONE\n" .
\ " call inputrestore()\n" .
\ " echo\n" .
\ " if len(a:000) == 0\n" .
\ " call " . new . "()\n" .
\ " else\n" .
Expand Down

0 comments on commit 47d8a9f

Please sign in to comment.