From 02d84a4cbf09033ee68676e0d23d6e3d994886d0 Mon Sep 17 00:00:00 2001 From: amdt Date: Sat, 8 Mar 2014 16:52:12 +0900 Subject: [PATCH] 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. --- plugin/youcompleteme.vim | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/plugin/youcompleteme.vim b/plugin/youcompleteme.vim index bfdad8db..bc697f2c 100644 --- a/plugin/youcompleteme.vim +++ b/plugin/youcompleteme.vim @@ -19,18 +19,26 @@ let s:save_cpo = &cpo set cpo&vim +function! s:restore_cpo() + let &cpo = s:save_cpo + unlet s:save_cpo +endfunction + if exists( "g:loaded_youcompleteme" ) + call s:restore_cpo() finish elseif v:version < 703 || (v:version == 703 && !has('patch584')) echohl WarningMsg | \ echomsg "YouCompleteMe unavailable: requires Vim 7.3.584+" | \ echohl None + call s:restore_cpo() finish elseif !has( 'python' ) echohl WarningMsg | \ echomsg "YouCompleteMe unavailable: requires Vim compiled with " . \ " Python 2.x support" | \ echohl None + call s:restore_cpo() finish 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 before using it. Read the docs!" | \ echohl None + call s:restore_cpo() finish endif @@ -152,5 +161,4 @@ augroup youcompletemeStart augroup END " This is basic vim plugin boilerplate -let &cpo = s:save_cpo -unlet s:save_cpo +call s:restore_cpo()