Use try-finally for reverting the setup

This commit is contained in:
Junegunn Choi
2013-09-19 17:27:26 +09:00
parent 1752bf567b
commit fce0a103ff

View File

@@ -92,16 +92,19 @@ let s:prev_echon_len = 0
function! s:echon_(msg) function! s:echon_(msg)
" http://vim.wikia.com/wiki/How_to_print_full_screen_width_messages " http://vim.wikia.com/wiki/How_to_print_full_screen_width_messages
let xy = [&ruler, &showcmd] let xy = [&ruler, &showcmd]
set noruler noshowcmd try
let winlen = winwidth(winnr()) - 2 set noruler noshowcmd
let msg = len(a:msg) > winlen ? (a:msg[0 : winlen - 3] . '..') : a:msg let winlen = winwidth(winnr()) - 2
let len = len(msg) let msg = len(a:msg) > winlen ? (a:msg[0 : winlen - 3] . '..') : a:msg
if len < s:prev_echon_len let len = len(msg)
echon "\r". repeat(' ', min([winlen, s:prev_echon_len])) if len < s:prev_echon_len
endif echon "\r". repeat(' ', min([winlen, s:prev_echon_len]))
echon "\r". msg endif
let s:prev_echon_len = len echon "\r". msg
let [&ruler, &showcmd] = xy let s:prev_echon_len = len
finally
let [&ruler, &showcmd] = xy
endtry
endfunction endfunction
function! s:echon(l, n, d, o) function! s:echon(l, n, d, o)