Revert "Only removing our signs in buffer, no all"

This reverts commit 182848050e.

The reason we are reverting this is because removing signs in a loop causes
flicker. The only non-flicker approach is to remove all signs in a buffer with
"sign unplace buffer=<buffer-num>".

So no compatibility with other plugins for us.
This commit is contained in:
Strahinja Val Markovic 2014-01-10 14:39:52 -08:00
parent 182848050e
commit 9d06a3e54c
2 changed files with 22 additions and 39 deletions

View File

@ -31,7 +31,6 @@ class DiagnosticInterface( object ):
self._next_sign_id = 1 self._next_sign_id = 1
self._previous_line_number = -1 self._previous_line_number = -1
self._diag_message_needs_clearing = False self._diag_message_needs_clearing = False
self._buffer_number_to_sign_ids = defaultdict( set )
def OnCursorMoved( self ): def OnCursorMoved( self ):
@ -48,7 +47,8 @@ class DiagnosticInterface( object ):
self._buffer_number_to_line_to_diags = _ConvertDiagListToDict( diags ) self._buffer_number_to_line_to_diags = _ConvertDiagListToDict( diags )
if self._user_options[ 'enable_diagnostic_signs' ]: if self._user_options[ 'enable_diagnostic_signs' ]:
self._UpdateSigns() self._next_sign_id = _UpdateSigns( self._buffer_number_to_line_to_diags,
self._next_sign_id )
if self._user_options[ 'enable_diagnostic_highlighting' ]: if self._user_options[ 'enable_diagnostic_highlighting' ]:
_UpdateSquiggles( self._buffer_number_to_line_to_diags ) _UpdateSquiggles( self._buffer_number_to_line_to_diags )
@ -71,40 +71,6 @@ class DiagnosticInterface( object ):
self._diag_message_needs_clearing = True self._diag_message_needs_clearing = True
def _UnplaceSignsInBuffer( self, buffer_number ):
vimsupport.UnplaceSignsInBuffer(
buffer_number,
self._buffer_number_to_sign_ids[ buffer_number ] )
self._buffer_number_to_sign_ids[ buffer_number ].clear()
def _PlaceSignInBuffer( self, line, buffer_number, is_error ):
vimsupport.PlaceSign( self._next_sign_id,
line,
buffer_number,
is_error )
self._buffer_number_to_sign_ids[ buffer_number ].add( self._next_sign_id )
self._next_sign_id += 1
def _UpdateSigns( self ):
self._UnplaceSignsInBuffer( vim.current.buffer.number )
for buffer_number, line_to_diags in \
self._buffer_number_to_line_to_diags.iteritems():
if not vimsupport.BufferIsVisible( buffer_number ):
continue
self._UnplaceSignsInBuffer( buffer_number )
for line, diags in line_to_diags.iteritems():
for diag in diags:
self._PlaceSignInBuffer( line,
buffer_number,
_DiagnosticIsError( diag ) )
def _UpdateSquiggles( buffer_number_to_line_to_diags ): def _UpdateSquiggles( buffer_number_to_line_to_diags ):
vimsupport.ClearYcmSyntaxMatches() vimsupport.ClearYcmSyntaxMatches()
line_to_diags = buffer_number_to_line_to_diags[ vim.current.buffer.number ] line_to_diags = buffer_number_to_line_to_diags[ vim.current.buffer.number ]
@ -136,6 +102,23 @@ def _UpdateSquiggles( buffer_number_to_line_to_diags ):
is_error = is_error ) is_error = is_error )
def _UpdateSigns( buffer_number_to_line_to_diags, next_sign_id ):
vimsupport.UnplaceAllSignsInBuffer( vim.current.buffer.number )
for buffer_number, line_to_diags in buffer_number_to_line_to_diags.iteritems():
if not vimsupport.BufferIsVisible( buffer_number ):
continue
vimsupport.UnplaceAllSignsInBuffer( buffer_number )
for line, diags in line_to_diags.iteritems():
for diag in diags:
vimsupport.PlaceSign( next_sign_id,
line,
buffer_number,
_DiagnosticIsError( diag ) )
next_sign_id += 1
return next_sign_id
def _ConvertDiagListToDict( diag_list ): def _ConvertDiagListToDict( diag_list ):
buffer_to_line_to_diags = defaultdict( lambda: defaultdict( list ) ) buffer_to_line_to_diags = defaultdict( lambda: defaultdict( list ) )
for diag in diag_list: for diag in diag_list:

View File

@ -107,11 +107,11 @@ def GetBufferFilepath( buffer_object ):
return os.path.join( os.getcwd(), str( buffer_object.number ) ) return os.path.join( os.getcwd(), str( buffer_object.number ) )
def UnplaceSignsInBuffer( buffer_number, signs ): # TODO: only unplace our signs, not all signs
def UnplaceAllSignsInBuffer( buffer_number ):
if buffer_number < 0: if buffer_number < 0:
return return
for sign in signs: vim.command( 'sign unplace * buffer={0}'.format( buffer_number ) )
vim.command( 'sign unplace {0} buffer={1}'.format( sign, buffer_number ) )
def PlaceSign( sign_id, line_num, buffer_num, is_error = True ): def PlaceSign( sign_id, line_num, buffer_num, is_error = True ):