Fixed bug: current buffer was not set correctly.

Other minor fixes.
This commit is contained in:
Davit Samvelyan 2017-06-10 09:53:18 +04:00
parent 22be4e777d
commit e5b0565d1a
4 changed files with 9 additions and 7 deletions

View File

@ -420,6 +420,8 @@ endfunction
function! s:OnFileTypeSet() function! s:OnFileTypeSet()
exec s:python_command "ycm_state.SetCurrentBuffer()"
if !s:AllowedToCompleteInCurrentBuffer() if !s:AllowedToCompleteInCurrentBuffer()
return return
endif endif

View File

@ -26,7 +26,6 @@ from future.utils import itervalues, iteritems
from collections import defaultdict, namedtuple from collections import defaultdict, namedtuple
from ycm import vimsupport from ycm import vimsupport
from ycm.diagnostic_filter import DiagnosticFilter, CompileLevel from ycm.diagnostic_filter import DiagnosticFilter, CompileLevel
import vim
class DiagnosticInterface( object ): class DiagnosticInterface( object ):
@ -120,13 +119,12 @@ class DiagnosticInterface( object ):
def _UpdateSquiggles( self ): def _UpdateSquiggles( self ):
if self._bufnr != vim.current.buffer.number:
return
vimsupport.ClearYcmSyntaxMatches() vimsupport.ClearYcmSyntaxMatches()
for diags in itervalues( self._line_to_diags ): 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' ] location_extent = diag[ 'location_extent' ]
is_error = _DiagnosticIsError( diag ) is_error = _DiagnosticIsError( diag )
@ -202,7 +200,7 @@ class DiagnosticInterface( object ):
for diags in itervalues( self._line_to_diags ): for diags in itervalues( self._line_to_diags ):
# We also want errors to be listed before warnings so that errors aren't # 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' ], diags.sort( key = lambda diag: ( diag[ 'kind' ],
diag[ 'location' ][ 'column_num' ] ) ) diag[ 'location' ][ 'column_num' ] ) )

View File

@ -139,6 +139,8 @@ def _MockVimOptionsEval( value ):
def _MockVimMatchEval( value ): def _MockVimMatchEval( value ):
if value == 'getmatches()': 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 ) return list( VIM_MATCHES )
match = MATCHADD_REGEX.search( value ) match = MATCHADD_REGEX.search( value )

View File

@ -524,9 +524,9 @@ def YouCompleteMe_UpdateDiagnosticInterface_PrioritizeErrorsOverWarnings_test(
assert_that( assert_that(
test_utils.VIM_MATCHES, test_utils.VIM_MATCHES,
contains( contains(
VimMatch( 'YcmErrorSection', '\%3l\%8c' ),
VimMatch( 'YcmWarningSection', '\%3l\%5c\_.\{-}\%3l\%7c' ), VimMatch( 'YcmWarningSection', '\%3l\%5c\_.\{-}\%3l\%7c' ),
VimMatch( 'YcmWarningSection', '\%3l\%3c\_.\{-}\%3l\%9c' ) VimMatch( 'YcmWarningSection', '\%3l\%3c\_.\{-}\%3l\%9c' ),
VimMatch( 'YcmErrorSection', '\%3l\%8c' )
) )
) )