Skip to content

Commit

Permalink
Working around a Vim bug that causes flickering.
Browse files Browse the repository at this point in the history
If the user had a hidden buffer and a recent version of Vim, the screen would
flicker every time the user typed. This was caused by a Vim bug.

On every key press, we end up calling GetUnsavedAndCurrentBufferData(), which
calls GetBufferOption( buffer_object, 'ft' ). If the buffer_object represents a
hidden buffer, Vim would flicker.

This would happen because we'd call "buffer_object.options[ 'ft' ]" in recent
versions of Vim, and that line of code causes Vim to flicker. I don't know why.
We're extracting the 'ft' value without going through buffer_object.options, and
that works just fine.

Fixes #669.
  • Loading branch information
Valloric committed Jan 6, 2014
1 parent 96b28b9 commit e8d1a4c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions python/ycm/vimsupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@ def TextAfterCursor():
# Note the difference between buffer OPTIONS and VARIABLES; the two are not
# the same.
def GetBufferOption( buffer_object, option ):
# The 'options' property is only available in recent (7.4+) Vim builds
if hasattr( buffer_object, 'options' ):
return buffer_object.options[ option ]
# NOTE: We used to check for the 'options' property on the buffer_object which
# is available in recent versions of Vim and would then use:
#
# buffer_object.options[ option ]
#
# to read the value, BUT this caused annoying flickering when the
# buffer_object was a hidden buffer (with option = 'ft'). This was all due to
# a Vim bug. Until this is fixed, we won't use it.

to_eval = 'getbufvar({0}, "&{1}")'.format( buffer_object.number, option )
return GetVariableValue( to_eval )
Expand Down

0 comments on commit e8d1a4c

Please sign in to comment.