completion: Use textEdited instead of textChanged
This gets rid of _ignore_next and some unneeded logic, since textEdited won't even emit if we edited it programatically.
This commit is contained in:
parent
903d1876af
commit
adfc96cdfa
@ -312,7 +312,7 @@ class QuteBrowser(QApplication):
|
|||||||
cmd.clear_completion_selection.connect(
|
cmd.clear_completion_selection.connect(
|
||||||
completion.on_clear_completion_selection)
|
completion.on_clear_completion_selection)
|
||||||
cmd.hide_completion.connect(completion.hide)
|
cmd.hide_completion.connect(completion.hide)
|
||||||
cmd.textChanged.connect(completion.on_cmd_text_changed)
|
cmd.textEdited.connect(completion.on_cmd_text_changed)
|
||||||
completion.change_completed_part.connect(cmd.on_change_completed_part)
|
completion.change_completed_part.connect(cmd.on_change_completed_part)
|
||||||
|
|
||||||
def _recover_pages(self):
|
def _recover_pages(self):
|
||||||
|
@ -59,7 +59,6 @@ class CompletionView(QTreeView):
|
|||||||
_model: The currently active filter model.
|
_model: The currently active filter model.
|
||||||
_lastmodel: The model set in the last iteration.
|
_lastmodel: The model set in the last iteration.
|
||||||
_completion_models: dict of available completion models.
|
_completion_models: dict of available completion models.
|
||||||
_ignore_next: Whether to ignore the next cmd_text_changed signal.
|
|
||||||
_enabled: Whether showing the CompletionView is enabled.
|
_enabled: Whether showing the CompletionView is enabled.
|
||||||
_completing: Whether we're currently completing something.
|
_completing: Whether we're currently completing something.
|
||||||
_height: The height to use for the CompletionView.
|
_height: The height to use for the CompletionView.
|
||||||
@ -124,7 +123,6 @@ class CompletionView(QTreeView):
|
|||||||
opt, self)))
|
opt, self)))
|
||||||
except NoCompletionsError:
|
except NoCompletionsError:
|
||||||
pass
|
pass
|
||||||
self._ignore_next = False
|
|
||||||
self._completing = False
|
self._completing = False
|
||||||
|
|
||||||
self._delegate = _CompletionItemDelegate(self)
|
self._delegate = _CompletionItemDelegate(self)
|
||||||
@ -219,7 +217,6 @@ class CompletionView(QTreeView):
|
|||||||
QItemSelectionModel.Rows)
|
QItemSelectionModel.Rows)
|
||||||
data = self._model.data(idx)
|
data = self._model.data(idx)
|
||||||
if data is not None:
|
if data is not None:
|
||||||
self._ignore_next = True
|
|
||||||
self.change_completed_part.emit(data)
|
self.change_completed_part.emit(data)
|
||||||
|
|
||||||
def set_model(self, model):
|
def set_model(self, model):
|
||||||
@ -254,11 +251,6 @@ class CompletionView(QTreeView):
|
|||||||
text: The new text
|
text: The new text
|
||||||
"""
|
"""
|
||||||
# FIXME we should also consider the cursor position
|
# FIXME we should also consider the cursor position
|
||||||
if self._ignore_next:
|
|
||||||
# Text changed by a completion, so we don't have to complete again.
|
|
||||||
self._ignore_next = False
|
|
||||||
return
|
|
||||||
|
|
||||||
if not text.startswith(':'):
|
if not text.startswith(':'):
|
||||||
# This is a search or gibberish, so we don't need to complete
|
# This is a search or gibberish, so we don't need to complete
|
||||||
# anything (yet)
|
# anything (yet)
|
||||||
|
Loading…
Reference in New Issue
Block a user