Restore cpoptions before calling finish

The user's 'cpoptions' are saved and restored when this script finishes
normally, however there are some cases where this script finishes early,
and where the user's 'cpoptions' are not restored beforehand.
This commit is contained in:
amdt 2014-03-08 16:52:12 +09:00
parent 321355b041
commit 02d84a4cbf

View File

@ -19,18 +19,26 @@
let s:save_cpo = &cpo let s:save_cpo = &cpo
set cpo&vim set cpo&vim
function! s:restore_cpo()
let &cpo = s:save_cpo
unlet s:save_cpo
endfunction
if exists( "g:loaded_youcompleteme" ) if exists( "g:loaded_youcompleteme" )
call s:restore_cpo()
finish finish
elseif v:version < 703 || (v:version == 703 && !has('patch584')) elseif v:version < 703 || (v:version == 703 && !has('patch584'))
echohl WarningMsg | echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires Vim 7.3.584+" | \ echomsg "YouCompleteMe unavailable: requires Vim 7.3.584+" |
\ echohl None \ echohl None
call s:restore_cpo()
finish finish
elseif !has( 'python' ) elseif !has( 'python' )
echohl WarningMsg | echohl WarningMsg |
\ echomsg "YouCompleteMe unavailable: requires Vim compiled with " . \ echomsg "YouCompleteMe unavailable: requires Vim compiled with " .
\ " Python 2.x support" | \ " Python 2.x support" |
\ echohl None \ echohl None
call s:restore_cpo()
finish finish
endif endif
@ -60,6 +68,7 @@ if g:ycm_check_if_ycm_core_present && !s:HasYcmCore()
\ "ycm_core.[so|pyd|dll] not detected; you need to compile " . \ "ycm_core.[so|pyd|dll] not detected; you need to compile " .
\ "YCM before using it. Read the docs!" | \ "YCM before using it. Read the docs!" |
\ echohl None \ echohl None
call s:restore_cpo()
finish finish
endif endif
@ -152,5 +161,4 @@ augroup youcompletemeStart
augroup END augroup END
" This is basic vim plugin boilerplate " This is basic vim plugin boilerplate
let &cpo = s:save_cpo call s:restore_cpo()
unlet s:save_cpo