Auto merge of #2614 - micbou:refactor-ycm-changedtick, r=Valloric

[READY] Refactor b:ycm_changedtick variable

Since we only use the `b:ycm_changedtick` variable to track the last time we parsed the buffer, we can change it to store a number instead of a dictionary.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2614)
<!-- Reviewable:end -->
This commit is contained in:
Homu 2017-04-12 05:38:59 +09:00
commit 5198fd9a09

View File

@ -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