Auto merge of #2595 - micbou:split-on-buffer-visit, r=Valloric
[READY] Split the OnBufferVisit function again We can't use `VisitedBufferRequiresReparse` for the `FileType` autocommand event because ycmd may parse a buffer differently depending on its filetype. We have to use `AllowedToCompleteInCurrentBuffer` for this event (we can also use it for the `BufRead` one). Fixes https://github.com/Valloric/ycmd/issues/731. <!-- 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/2595) <!-- Reviewable:end -->
This commit is contained in:
commit
98bd093e20
@ -90,7 +90,8 @@ function! youcompleteme#Enable()
|
||||
" We also need to trigger buf init code on the FileType event because when
|
||||
" the user does :enew and then :set ft=something, we need to run buf init
|
||||
" code again.
|
||||
autocmd BufRead,BufEnter,FileType * call s:OnBufferVisit()
|
||||
autocmd BufRead,FileType * call s:OnBufferRead()
|
||||
autocmd BufEnter * call s:OnBufferEnter()
|
||||
autocmd BufUnload * call s:OnBufferUnload()
|
||||
autocmd CursorHold,CursorHoldI * call s:OnCursorHold()
|
||||
autocmd InsertLeave * call s:OnInsertLeave()
|
||||
@ -100,7 +101,7 @@ function! youcompleteme#Enable()
|
||||
augroup END
|
||||
|
||||
" BufRead/FileType events are not triggered for the first loaded file.
|
||||
" However, we don't directly call the s:OnBufferVisit function because it
|
||||
" However, we don't directly call the s:OnBufferRead function because it
|
||||
" would send requests that can't succeed as the server is not ready yet and
|
||||
" would slow down startup.
|
||||
if s:AllowedToCompleteInCurrentBuffer()
|
||||
@ -425,12 +426,26 @@ function! s:OnCompleteDone()
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:OnBufferVisit()
|
||||
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
|
||||
|
||||
call s:SetUpCompleteopt()
|
||||
call s:SetCompleteFunc()
|
||||
call s:SetOmnicompleteFunc()
|
||||
|
||||
exec s:python_command "ycm_state.OnBufferVisit()"
|
||||
call s:OnFileReadyToParse()
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:OnBufferEnter()
|
||||
if !s:VisitedBufferRequiresReparse()
|
||||
return
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user