From ac1e04fc14cd136270b938cd8a8f13ead0bf572d Mon Sep 17 00:00:00 2001 From: Zeh Rizzatti Date: Sat, 2 Mar 2013 22:14:22 -0400 Subject: [PATCH] Check for a native completer with multiple filetypes GetFiletypeCompleter would always return a omnicompleter for the first filetype in case there was no native completer, and the lookup would stop. This changes that behaviour to get all possible completers and tries to find a native one among them. If no native completer is found, it returns the omnicompleter for the first filetypes, as it used to. --- python/ycm.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/python/ycm.py b/python/ycm.py index f39ee81a..e027a86c 100644 --- a/python/ycm.py +++ b/python/ycm.py @@ -60,11 +60,19 @@ class YouCompleteMe( object ): def GetFiletypeCompleter( self ): filetypes = vimsupport.CurrentFiletypes() - for filetype in filetypes: - completer = self.GetFiletypeCompleterForFiletype( filetype ) - if completer: + completers = [self.GetFiletypeCompleterForFiletype( filetype ) + for filetype in filetypes ] + + if not completers: + return None + + # Try to find a native completer first + for completer in completers: + if completer and completer is not self.omnicomp: return completer - return None + + # Return the omni completer for the first filetype + return completers[0] def GetFiletypeCompleterForFiletype( self, filetype ):