Auto merge of #2487 - micbou:large-file, r=puremourning
[READY] Fix large file message appearing twice In PR #2469, we moved the large file logic inside `s:OnBufferRead` but forgot this function was not only called on the `BufRead` event but also on the `FileType` one. This makes the large file message appears twice when opening such file. We fix that by not displaying the message when the `b:ycm_largefile` variable is already set. Also, the message is now displayed with `PostVimMessage` to avoid the `Press ENTER or type command to continue` prompt. Fixes #2485. <!-- 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/2487) <!-- Reviewable:end -->
This commit is contained in:
commit
3828cfd2fd
@ -333,8 +333,8 @@ function! s:AllowedToCompleteInBuffer( buffer )
|
|||||||
let buffer_filetype = getbufvar( a:buffer, '&filetype' )
|
let buffer_filetype = getbufvar( a:buffer, '&filetype' )
|
||||||
|
|
||||||
if empty( buffer_filetype ) ||
|
if empty( buffer_filetype ) ||
|
||||||
\ getbufvar( a:buffer, '&buftype' ) ==# 'nofile' ||
|
\ getbufvar( a:buffer, '&buftype' ) ==# 'nofile' ||
|
||||||
\ buffer_filetype ==# 'qf'
|
\ buffer_filetype ==# 'qf'
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -373,9 +373,9 @@ function! s:SetUpCommands()
|
|||||||
command! YcmShowDetailedDiagnostic call s:ShowDetailedDiagnostic()
|
command! YcmShowDetailedDiagnostic call s:ShowDetailedDiagnostic()
|
||||||
command! YcmDebugInfo call s:DebugInfo()
|
command! YcmDebugInfo call s:DebugInfo()
|
||||||
command! -nargs=* -complete=custom,youcompleteme#LogsComplete
|
command! -nargs=* -complete=custom,youcompleteme#LogsComplete
|
||||||
\ YcmToggleLogs call s:ToggleLogs(<f-args>)
|
\ YcmToggleLogs call s:ToggleLogs(<f-args>)
|
||||||
command! -nargs=* -complete=custom,youcompleteme#SubCommandsComplete
|
command! -nargs=* -complete=custom,youcompleteme#SubCommandsComplete
|
||||||
\ YcmCompleter call s:CompleterCommand(<f-args>)
|
\ YcmCompleter call s:CompleterCommand(<f-args>)
|
||||||
command! YcmForceCompileAndDiagnostics call s:ForceCompileAndDiagnostics()
|
command! YcmForceCompileAndDiagnostics call s:ForceCompileAndDiagnostics()
|
||||||
command! YcmDiags call s:ShowDiagnostics()
|
command! YcmDiags call s:ShowDiagnostics()
|
||||||
endfunction
|
endfunction
|
||||||
@ -431,13 +431,16 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! s:DisableOnLargeFile( filename )
|
function! s:DisableOnLargeFile( filename )
|
||||||
|
if exists( 'b:ycm_largefile' )
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
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
|
||||||
echohl WarningMsg |
|
exec s:python_command "vimsupport.PostVimMessage(" .
|
||||||
\ echomsg "YouCompleteMe is disabled in this buffer; " .
|
\ "'YouCompleteMe is disabled in this buffer; " .
|
||||||
\ "the file exceeded the max size (see YCM options)." |
|
\ "the file exceeded the max size (see YCM options).' )"
|
||||||
\ echohl None
|
|
||||||
let b:ycm_largefile = 1
|
let b:ycm_largefile = 1
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -495,7 +498,7 @@ function! s:OnBufferUnload()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let deleted_buffer_file = expand( '<afile>:p' )
|
let deleted_buffer_file = expand( '<afile>:p' )
|
||||||
exec s:python_command "ycm_state.OnBufferUnload("
|
exec s:python_command "ycm_state.OnBufferUnload(" .
|
||||||
\ "vim.eval( 'deleted_buffer_file' ) )"
|
\ "vim.eval( 'deleted_buffer_file' ) )"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -754,7 +757,7 @@ function! youcompleteme#OmniComplete( findstart, base )
|
|||||||
return -2
|
return -2
|
||||||
endif
|
endif
|
||||||
let s:omnifunc_mode = 1
|
let s:omnifunc_mode = 1
|
||||||
exec s:python_command "ycm_state.CreateCompletionRequest("
|
exec s:python_command "ycm_state.CreateCompletionRequest(" .
|
||||||
\ "force_semantic = True )"
|
\ "force_semantic = True )"
|
||||||
return s:Pyeval( 'base.CompletionStartColumn()' )
|
return s:Pyeval( 'base.CompletionStartColumn()' )
|
||||||
else
|
else
|
||||||
@ -810,15 +813,15 @@ function! s:CompleterCommand(...)
|
|||||||
let arguments = arguments[1:]
|
let arguments = arguments[1:]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
exec s:python_command "ycm_state.SendCommandRequest("
|
exec s:python_command "ycm_state.SendCommandRequest(" .
|
||||||
\ "vim.eval( 'l:arguments' ), vim.eval( 'l:completer' ) ) "
|
\ "vim.eval( 'l:arguments' ), vim.eval( 'l:completer' ) )"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! youcompleteme#OpenGoToList()
|
function! youcompleteme#OpenGoToList()
|
||||||
exec s:python_command "vimsupport.PostVimMessage("
|
exec s:python_command "vimsupport.PostVimMessage(" .
|
||||||
\ "'WARNING: youcompleteme#OpenGoToList function is deprecated."
|
\ "'WARNING: youcompleteme#OpenGoToList function is deprecated. " .
|
||||||
\ "Do NOT use it.')"
|
\ "Do NOT use it.' )"
|
||||||
exec s:python_command "vimsupport.OpenQuickFixList( True, True )"
|
exec s:python_command "vimsupport.OpenQuickFixList( True, True )"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -835,8 +838,8 @@ endfunction
|
|||||||
|
|
||||||
function! s:ForceCompile()
|
function! s:ForceCompile()
|
||||||
if !s:Pyeval( 'ycm_state.NativeFiletypeCompletionUsable()' )
|
if !s:Pyeval( 'ycm_state.NativeFiletypeCompletionUsable()' )
|
||||||
echom "Native filetype completion not supported for current file, "
|
echom "Native filetype completion not supported for current file, " .
|
||||||
\ . "cannot force recompilation."
|
\ "cannot force recompilation."
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user