From e8d1a4cef854e61983984b6c810d4ebddac9c1f5 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Mon, 6 Jan 2014 15:00:51 -0800 Subject: [PATCH] Working around a Vim bug that causes flickering. 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. --- python/ycm/vimsupport.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py index 56bd9765..e3a3c0ea 100644 --- a/python/ycm/vimsupport.py +++ b/python/ycm/vimsupport.py @@ -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 )