From 4b039e21020d0ef0ea24145a915c2e4417aab854 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sat, 11 May 2013 13:49:48 -0700 Subject: [PATCH] Using BufUnload instead of BufDelete Seems to be more robust. This should help with memory consumption when using the clang_completer. See issue #184. --- autoload/youcompleteme.vim | 6 +++--- python/completers/completer.py | 2 +- python/completers/cpp/clang_completer.py | 2 +- python/completers/general/general_completer_store.py | 4 ++-- python/ycm.py | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 7ff76d8c..98cbf650 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -63,7 +63,7 @@ function! youcompleteme#Enable() " that happens *after" BufRead/BufEnter has already triggered for the " initial file. autocmd BufRead,BufEnter * call s:OnBufferVisit() - autocmd BufDelete * call s:OnBufferDelete( expand( ':p' ) ) + autocmd BufUnload * call s:OnBufferUnload( expand( ':p' ) ) autocmd CursorHold,CursorHoldI * call s:OnCursorHold() autocmd InsertLeave * call s:OnInsertLeave() autocmd InsertEnter * call s:OnInsertEnter() @@ -222,12 +222,12 @@ function! s:OnBufferVisit() endfunction -function! s:OnBufferDelete( deleted_buffer_file ) +function! s:OnBufferUnload( deleted_buffer_file ) if !s:AllowedToCompleteInCurrentFile() || empty( a:deleted_buffer_file ) return endif - py ycm_state.OnBufferDelete( vim.eval( 'a:deleted_buffer_file' ) ) + py ycm_state.OnBufferUnload( vim.eval( 'a:deleted_buffer_file' ) ) endfunction diff --git a/python/completers/completer.py b/python/completers/completer.py index f6a2c516..1c1ae842 100644 --- a/python/completers/completer.py +++ b/python/completers/completer.py @@ -262,7 +262,7 @@ class Completer( object ): pass - def OnBufferDelete( self, deleted_buffer_file ): + def OnBufferUnload( self, deleted_buffer_file ): pass diff --git a/python/completers/cpp/clang_completer.py b/python/completers/cpp/clang_completer.py index 8e689321..cedcabf3 100644 --- a/python/completers/cpp/clang_completer.py +++ b/python/completers/cpp/clang_completer.py @@ -225,7 +225,7 @@ class ClangCompleter( Completer ): flags ) - def OnBufferDelete( self, deleted_buffer_file ): + def OnBufferUnload( self, deleted_buffer_file ): self.completer.DeleteCachesForFileAsync( deleted_buffer_file ) diff --git a/python/completers/general/general_completer_store.py b/python/completers/general/general_completer_store.py index 3269ed6a..badfa9fb 100644 --- a/python/completers/general/general_completer_store.py +++ b/python/completers/general/general_completer_store.py @@ -115,9 +115,9 @@ class GeneralCompleterStore( Completer ): completer.OnBufferVisit() - def OnBufferDelete( self, deleted_buffer_file ): + def OnBufferUnload( self, deleted_buffer_file ): for completer in self._all_completers: - completer.OnBufferDelete( deleted_buffer_file ) + completer.OnBufferUnload( deleted_buffer_file ) def OnCursorHold( self ): diff --git a/python/ycm.py b/python/ycm.py index b6075600..74ba797a 100644 --- a/python/ycm.py +++ b/python/ycm.py @@ -138,11 +138,11 @@ class YouCompleteMe( object ): self.GetFiletypeCompleter().OnFileReadyToParse() - def OnBufferDelete( self, deleted_buffer_file ): - self.gencomp.OnBufferDelete( deleted_buffer_file ) + def OnBufferUnload( self, deleted_buffer_file ): + self.gencomp.OnBufferUnload( deleted_buffer_file ) if self.FiletypeCompletionUsable(): - self.GetFiletypeCompleter().OnBufferDelete( deleted_buffer_file ) + self.GetFiletypeCompleter().OnBufferUnload( deleted_buffer_file ) def OnBufferVisit( self ):