From c6aefaef86d44472dc41dab8714790833c84601d Mon Sep 17 00:00:00 2001 From: Zeh Rizzatti Date: Sun, 3 Mar 2013 01:52:56 -0400 Subject: [PATCH] Select correct triggers for multiple filetypes The base class completer Inner chose the first filetype available and would use the triggers for it. The triggers are now chosen considering the first for the current buffer that is supported by the current completer. If there is no intersection, it fallsback to considering the first filetype for the buffer. --- python/completers/completer.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/python/completers/completer.py b/python/completers/completer.py index fbdcf67e..f96aed49 100644 --- a/python/completers/completer.py +++ b/python/completers/completer.py @@ -134,7 +134,7 @@ class Completer( object ): if not line_length or start_column - 1 >= line_length: return False - filetype = vimsupport.CurrentFiletypes()[ 0 ] + filetype = self._CurrentFiletype() triggers = self.triggers_for_filetype[ filetype ] for trigger in triggers: @@ -266,6 +266,17 @@ class Completer( object ): return False + def _CurrentFiletype( self ): + filetypes = vimsupport.CurrentFiletypes() + supported = self.SupportedFiletypes() + + for filetype in filetypes: + if filetype in supported: + return filetype + + return filetypes[0] + + @abc.abstractmethod def SupportedFiletypes( self ): pass