Do not use BufReadPre autocommand
This autocommand has a bug that causes the cursor to move to the first line of the current buffer when using the pedit command.
This commit is contained in:
parent
39be8b1aad
commit
1511ee542f
@ -88,7 +88,6 @@ function! youcompleteme#Enable()
|
|||||||
" We also need to trigger buf init code on the FileType event because when
|
" 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
|
" the user does :enew and then :set ft=something, we need to run buf init
|
||||||
" code again.
|
" code again.
|
||||||
autocmd BufReadPre * call s:OnBufferReadPre( expand( '<afile>:p' ) )
|
|
||||||
autocmd BufRead,FileType * call s:OnBufferRead()
|
autocmd BufRead,FileType * call s:OnBufferRead()
|
||||||
autocmd BufEnter * call s:OnBufferEnter()
|
autocmd BufEnter * call s:OnBufferEnter()
|
||||||
autocmd BufUnload * call s:OnBufferUnload()
|
autocmd BufUnload * call s:OnBufferUnload()
|
||||||
@ -112,10 +111,9 @@ function! youcompleteme#Enable()
|
|||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Calling these once solves the problem of BufReadPre/BufRead/BufEnter not
|
" Calling this once solves the problem of BufRead/BufEnter not triggering for
|
||||||
" triggering for the first loaded file. This should be the last commands
|
" the first loaded file. This should be the last command executed in this
|
||||||
" executed in this function!
|
" function!
|
||||||
call s:OnBufferReadPre( expand( '<afile>:p' ) )
|
|
||||||
call s:OnBufferRead()
|
call s:OnBufferRead()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -432,17 +430,7 @@ function! s:SetUpYcmChangedTick()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:OnVimLeave()
|
function! s:DisableOnLargeFile( filename )
|
||||||
exec s:python_command "ycm_state.OnVimLeave()"
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! s:OnCompleteDone()
|
|
||||||
exec s:python_command "ycm_state.OnCompleteDone()"
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
|
||||||
function! s:OnBufferReadPre(filename)
|
|
||||||
let threshold = g:ycm_disable_for_files_larger_than_kb * 1024
|
let threshold = g:ycm_disable_for_files_larger_than_kb * 1024
|
||||||
|
|
||||||
if threshold > 0 && getfsize( a:filename ) > threshold
|
if threshold > 0 && getfsize( a:filename ) > threshold
|
||||||
@ -455,12 +443,24 @@ function! s:OnBufferReadPre(filename)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! s:OnVimLeave()
|
||||||
|
exec s:python_command "ycm_state.OnVimLeave()"
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! s:OnCompleteDone()
|
||||||
|
exec s:python_command "ycm_state.OnCompleteDone()"
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:OnBufferRead()
|
function! s:OnBufferRead()
|
||||||
" We need to do this even when we are not allowed to complete in the current
|
" 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
|
" 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.
|
" example is creating a new buffer with :enew and then setting a filetype.
|
||||||
call s:SetUpYcmChangedTick()
|
call s:SetUpYcmChangedTick()
|
||||||
|
|
||||||
|
call s:DisableOnLargeFile( expand( '<afile>:p' ) )
|
||||||
|
|
||||||
if !s:AllowedToCompleteInCurrentBuffer()
|
if !s:AllowedToCompleteInCurrentBuffer()
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user