From 8af0f5183ec11890396bea0009732d680d7f20e6 Mon Sep 17 00:00:00 2001 From: micbou Date: Mon, 6 Mar 2017 07:32:03 +0100 Subject: [PATCH] Refactor b:ycm_changedtick variable --- autoload/youcompleteme.vim | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 409490e0..c4b02262 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -404,18 +404,6 @@ function! s:SetUpCompleteopt() endfunction -" For various functions/use-cases, we want to keep track of whether the buffer -" has changed since the last time they were invoked. We keep the state of -" b:changedtick of the last time the specific function was called in -" b:ycm_changedtick. -function! s:SetUpYcmChangedTick() - let b:ycm_changedtick = - \ get( b:, 'ycm_changedtick', { - \ 'file_ready_to_parse' : -1, - \ } ) -endfunction - - function! s:OnVimLeave() exec s:python_command "ycm_state.OnVimLeave()" endfunction @@ -427,11 +415,6 @@ endfunction function! s:OnBufferRead() - " We need to do this even when we are not allowed to complete in the current - " buffer because we might be allowed to complete in the future! The canonical - " example is creating a new buffer with :enew and then setting a filetype. - call s:SetUpYcmChangedTick() - if !s:AllowedToCompleteInCurrentBuffer() return endif @@ -496,21 +479,18 @@ function! s:OnFileReadyToParse() return endif - " We need to call this just in case there is no b:ycm_changetick; this can - " happen for special buffers. - call s:SetUpYcmChangedTick() - " Order is important here; we need to extract any information before " reparsing the file again. If we sent the new parse request first, then " the response would always be pending when we called " HandleFileParseRequest. exec s:python_command "ycm_state.HandleFileParseRequest()" - let buffer_changed = b:changedtick != b:ycm_changedtick.file_ready_to_parse - if buffer_changed + " We only want to send a new FileReadyToParse event notification if the buffer + " has changed since the last time we sent one. + if b:changedtick != get( b:, 'ycm_changedtick', -1 ) exec s:python_command "ycm_state.OnFileReadyToParse()" + let b:ycm_changedtick = b:changedtick endif - let b:ycm_changedtick.file_ready_to_parse = b:changedtick endfunction