'Change the completed part if a new item was selected.
Called from the views selectionChanged method.
Args:
text: Newly selected text.'

@pyqtSlot(str)
def on_selection_changed(self, text):

    if (text is None):
        return
    (before, center, after) = self._partition()
    log.completion.debug("Changing    {}    to    '{}'".format(center, text))
    try:
        maxsplit = cmdutils.cmd_dict[before[0]].maxsplit
    except (KeyError, IndexError):
        maxsplit = None
    if (maxsplit is None):
        text = self._quote(text)
    model = self._model()
    if ((model.count() == 1) and config.get('completion', 'quick-complete')):
        self._change_completed_part(text, before, after, immediate=True)
        if ((maxsplit is not None) and (maxsplit < len(before))):
            self._ignore_change = True
    else:
        log.completion.debug('Will    ignore    next    completion    update.')
        self._ignore_change = True
        self._change_completed_part(text, before, after)
