Refactor b:ycm_changedtick variable
This commit is contained in:
parent
afd4071d03
commit
8af0f5183e
@ -404,18 +404,6 @@ function! s:SetUpCompleteopt()
|
|||||||
endfunction
|
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()
|
function! s:OnVimLeave()
|
||||||
exec s:python_command "ycm_state.OnVimLeave()"
|
exec s:python_command "ycm_state.OnVimLeave()"
|
||||||
endfunction
|
endfunction
|
||||||
@ -427,11 +415,6 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! s:OnBufferRead()
|
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()
|
if !s:AllowedToCompleteInCurrentBuffer()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@ -496,21 +479,18 @@ function! s:OnFileReadyToParse()
|
|||||||
return
|
return
|
||||||
endif
|
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
|
" Order is important here; we need to extract any information before
|
||||||
" reparsing the file again. If we sent the new parse request first, then
|
" reparsing the file again. If we sent the new parse request first, then
|
||||||
" the response would always be pending when we called
|
" the response would always be pending when we called
|
||||||
" HandleFileParseRequest.
|
" HandleFileParseRequest.
|
||||||
exec s:python_command "ycm_state.HandleFileParseRequest()"
|
exec s:python_command "ycm_state.HandleFileParseRequest()"
|
||||||
|
|
||||||
let buffer_changed = b:changedtick != b:ycm_changedtick.file_ready_to_parse
|
" We only want to send a new FileReadyToParse event notification if the buffer
|
||||||
if buffer_changed
|
" has changed since the last time we sent one.
|
||||||
|
if b:changedtick != get( b:, 'ycm_changedtick', -1 )
|
||||||
exec s:python_command "ycm_state.OnFileReadyToParse()"
|
exec s:python_command "ycm_state.OnFileReadyToParse()"
|
||||||
|
let b:ycm_changedtick = b:changedtick
|
||||||
endif
|
endif
|
||||||
let b:ycm_changedtick.file_ready_to_parse = b:changedtick
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user