diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 3002e885..404b493a 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -370,6 +370,13 @@ function! s:OnCursorMovedInsertMode() if g:ycm_auto_trigger || s:omnifunc_mode call s:InvokeCompletion() endif + + " We have to make sure we correctly leave omnifunc mode even when the user + " inserts something like a "operator[]" candidate string which fails + " CurrentIdentifierFinished check. + if s:omnifunc_mode && !pyeval( 'base.LastEnteredCharIsIdentifierChar()') + let s:omnifunc_mode = 0 + endif endfunction diff --git a/python/ycm/base.py b/python/ycm/base.py index e578fa3b..2d0c2f7d 100644 --- a/python/ycm/base.py +++ b/python/ycm/base.py @@ -93,6 +93,20 @@ def CurrentIdentifierFinished(): return line[ : current_column ].isspace() +def LastEnteredCharIsIdentifierChar(): + current_column = vimsupport.CurrentColumn() + previous_char_index = current_column - 1 + if previous_char_index < 0: + return False + line = vim.current.line + try: + previous_char = line[ previous_char_index ] + except IndexError: + return False + + return utils.IsIdentifierChar( previous_char ) + + def AdjustCandidateInsertionText( candidates ): """This function adjusts the candidate insertion text to take into account the text that's currently in front of the cursor.