add adjustable amount of chars required to update completions

This commit is contained in:
Joakim Reinert 2017-09-27 13:41:06 +02:00
parent 019d66a4c6
commit 0226025308
2 changed files with 16 additions and 2 deletions

View File

@ -197,9 +197,16 @@ class Completer(QObject):
For performance reasons we don't want to block here, instead we do this
in the background.
We delay the update only if we've already input some text.
We delay the update only if we've already input some text and ignore
updates if the text is shorter than completion.min_chars (unless we're
hitting backspace in which case updates won't be ignored).
"""
if (self._cmd.cursorPosition() == self._last_cursor_pos and
cmd, _sep, rest = self._cmd.text().partition(' ')
if (0 < len(rest) < config.val.completion.min_chars and
self._cmd.cursorPosition() > self._last_cursor_pos):
log.completion.debug("Ignoring update because the length of "
"the text is less than completion.min_chars.")
elif (self._cmd.cursorPosition() == self._last_cursor_pos and
self._cmd.text() == self._last_text):
log.completion.debug("Ignoring update because there were no "
"changes.")

View File

@ -663,6 +663,13 @@ completion.delay:
minval: 0
desc: Delay in ms before updating completions after typing a character
completion.min_chars:
default: 1
type:
name: Int
minval: 1
desc: Minimum amount of characters needed to update completions
## downloads
downloads.location.directory: