Fix crash when there's no completion.

This commit is contained in:
Florian Bruhin 2015-08-24 00:08:55 +02:00
parent 70243d6e2f
commit 4577659342

View File

@ -138,7 +138,7 @@ class Completer(QObject):
cursor_part: The part the cursor is in.
Return:
A completion model.
A completion model or None.
"""
if completion == usertypes.Completion.option:
section = parts[cursor_part - 1]
@ -153,7 +153,11 @@ class Completer(QObject):
model = None
else:
model = instances.get(completion)
return sortfilter.CompletionFilterModel(source=model, parent=self)
if model is None:
return None
else:
return sortfilter.CompletionFilterModel(source=model, parent=self)
def _filter_cmdline_parts(self, parts, cursor_part):
"""Filter a list of commandline parts to exclude flags.