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.
This commit is contained in:
Zeh Rizzatti 2013-03-03 01:52:56 -04:00
parent ac1e04fc14
commit c6aefaef86

View File

@ -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