Auto merge of #2469 - micbou:remove-bufreadpre-autocommand, r=micbou
[READY] Do not use BufReadPre autocommand This autocommand has a bug that makes the cursor goes to the first line of the current buffer when opening the preview window with `:pedit`. Since the `BufRead` autocommand is always called after, we can drop it by moving the `s:OnBufferReadPre` logic into the `s:OnBufferRead` function. Fixes #2466. <!-- 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/2469) <!-- Reviewable:end -->
This commit is contained in:
commit
86ccd88980
@ -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