From e5b0565d1a804e6383e4b4c54150b5cdd263238d Mon Sep 17 00:00:00 2001 From: Davit Samvelyan Date: Sat, 10 Jun 2017 09:53:18 +0400 Subject: [PATCH] Fixed bug: current buffer was not set correctly. Other minor fixes. --- autoload/youcompleteme.vim | 2 ++ python/ycm/diagnostic_interface.py | 8 +++----- python/ycm/tests/test_utils.py | 2 ++ python/ycm/tests/youcompleteme_test.py | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 673cbfa9..68acc3ea 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -420,6 +420,8 @@ endfunction function! s:OnFileTypeSet() + exec s:python_command "ycm_state.SetCurrentBuffer()" + if !s:AllowedToCompleteInCurrentBuffer() return endif diff --git a/python/ycm/diagnostic_interface.py b/python/ycm/diagnostic_interface.py index 4593428c..f3621c10 100644 --- a/python/ycm/diagnostic_interface.py +++ b/python/ycm/diagnostic_interface.py @@ -26,7 +26,6 @@ from future.utils import itervalues, iteritems from collections import defaultdict, namedtuple from ycm import vimsupport from ycm.diagnostic_filter import DiagnosticFilter, CompileLevel -import vim class DiagnosticInterface( object ): @@ -120,13 +119,12 @@ class DiagnosticInterface( object ): def _UpdateSquiggles( self ): - if self._bufnr != vim.current.buffer.number: - return vimsupport.ClearYcmSyntaxMatches() for diags in itervalues( self._line_to_diags ): - for diag in diags: + # Insert squiggles in reverse order so that errors overlap warnings. + for diag in reversed( diags ): location_extent = diag[ 'location_extent' ] is_error = _DiagnosticIsError( diag ) @@ -202,7 +200,7 @@ class DiagnosticInterface( object ): for diags in itervalues( self._line_to_diags ): # We also want errors to be listed before warnings so that errors aren't - # hidden by the warnings; Vim won't place a sign oven an existing one. + # hidden by the warnings; Vim won't place a sign over an existing one. diags.sort( key = lambda diag: ( diag[ 'kind' ], diag[ 'location' ][ 'column_num' ] ) ) diff --git a/python/ycm/tests/test_utils.py b/python/ycm/tests/test_utils.py index f6f8cf97..dce230f5 100644 --- a/python/ycm/tests/test_utils.py +++ b/python/ycm/tests/test_utils.py @@ -139,6 +139,8 @@ def _MockVimOptionsEval( value ): def _MockVimMatchEval( value ): if value == 'getmatches()': + # Returning a copy, because ClearYcmSyntaxMatches() gets the result of + # getmatches(), iterates over it and removes elements from VIM_MATCHES. return list( VIM_MATCHES ) match = MATCHADD_REGEX.search( value ) diff --git a/python/ycm/tests/youcompleteme_test.py b/python/ycm/tests/youcompleteme_test.py index e71e4422..5538f1ba 100644 --- a/python/ycm/tests/youcompleteme_test.py +++ b/python/ycm/tests/youcompleteme_test.py @@ -524,9 +524,9 @@ def YouCompleteMe_UpdateDiagnosticInterface_PrioritizeErrorsOverWarnings_test( assert_that( test_utils.VIM_MATCHES, contains( - VimMatch( 'YcmErrorSection', '\%3l\%8c' ), VimMatch( 'YcmWarningSection', '\%3l\%5c\_.\{-}\%3l\%7c' ), - VimMatch( 'YcmWarningSection', '\%3l\%3c\_.\{-}\%3l\%9c' ) + VimMatch( 'YcmWarningSection', '\%3l\%3c\_.\{-}\%3l\%9c' ), + VimMatch( 'YcmErrorSection', '\%3l\%8c' ) ) )