Fix detailed messages with newline characters

This commit is contained in:
w0rp
2017-03-04 23:55:12 +00:00
parent c1947d13cf
commit 76df2d393b
2 changed files with 19 additions and 8 deletions

View File

@@ -23,16 +23,19 @@ function! s:EchoWithShortMess(setting, message) abort
let l:shortmess_options = getbufvar('%', '&shortmess')
try
" Turn shormess on or off.
" Turn shortmess on or off.
if a:setting ==# 'on'
setlocal shortmess+=T
" echomsg is neede for the message to get truncated and appear in
" the message history.
exec "norm! :echomsg a:message\n"
elseif a:setting ==# 'off'
setlocal shortmess-=T
" Regular echo is needed for printing newline characters.
echo a:message
else
throw 'Invalid setting: ' . string(a:setting)
endif
exec "norm! :echomsg a:message\n"
finally
call setbufvar('%', '&shortmess', l:shortmess_options)
endtry