Completer: don't try to partition search.

Exit before trying to partition if the command prefix is not ':'.

Resolves #1969:
'TypeError with refactored completion when searching for command'
This commit is contained in:
Ryan Roden-Corrent 2016-09-21 07:08:34 -04:00
parent 49f8fa6d76
commit 1d2cf3b648
2 changed files with 6 additions and 5 deletions

View File

@ -226,11 +226,6 @@ class Completer(QObject):
@pyqtSlot()
def _update_completion(self):
"""Check if completions are available and activate them."""
before_cursor, pattern, after_cursor = self._partition()
log.completion.debug("Updating completion: {} {} {}".format(
before_cursor, pattern, after_cursor))
if self._ignore_change:
log.completion.debug("Ignoring completion update because "
"ignore_change is True.")
@ -247,6 +242,11 @@ class Completer(QObject):
completion.set_model(None)
return
before_cursor, pattern, after_cursor = self._partition()
log.completion.debug("Updating completion: {} {} {}".format(
before_cursor, pattern, after_cursor))
pattern = pattern.strip("'\"")
model = self._get_new_completion(before_cursor, pattern)

View File

@ -180,6 +180,7 @@ def _set_cmd_prompt(cmd, txt):
(':set -t -p |', usertypes.Completion.section, ''),
(':open -- |', None, ''),
(':gibberish nonesense |', None, ''),
('/:help|', None, ''),
])
def test_update_completion(txt, kind, pattern, status_command_stub,
completer_obj, completion_widget_stub):