From 0226025308819df0381887e42ec14287d9e7c65b Mon Sep 17 00:00:00 2001 From: Joakim Reinert Date: Wed, 27 Sep 2017 13:41:06 +0200 Subject: [PATCH] add adjustable amount of chars required to update completions --- qutebrowser/completion/completer.py | 11 +++++++++-- qutebrowser/config/configdata.yml | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/qutebrowser/completion/completer.py b/qutebrowser/completion/completer.py index 23c77b59a..aa7f170a9 100644 --- a/qutebrowser/completion/completer.py +++ b/qutebrowser/completion/completer.py @@ -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.") diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 71ab4c8b0..23349de29 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -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: