'Check if completions are available and activate them.'

@pyqtSlot()
def _update_completion(self):

    if self._ignore_change:
        log.completion.debug('Ignoring    completion    update    because    ignore_change    is    True.')
        self._ignore_change = False
        return
    completion = self.parent()
    if (self._cmd.prefix() != ':'):
        completion.set_model(None)
        self._last_completion_func = None
        return
    (before_cursor, pattern, after_cursor) = self._partition()
    log.completion.debug('Updating    completion:    {}    {}    {}'.format(before_cursor, pattern, after_cursor))
    pattern = pattern.strip('\'"')
    func = self._get_new_completion(before_cursor, pattern)
    if (func is None):
        log.completion.debug('Clearing    completion')
        completion.set_model(None)
        self._last_completion_func = None
        return
    if (func != self._last_completion_func):
        self._last_completion_func = func
        args = (x for x in before_cursor[1:] if (not x.startswith('-')))
        with debug.log_time(log.completion, 'Starting    {}    completion'.format(func.__name__)):
            model = func(*args)
        with debug.log_time(log.completion, 'Set    completion    model'):
            completion.set_model(model)
    completion.set_pattern(pattern)
