From df26d4ad910f1119f33c1b79621d394cf713aa8f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 8 Mar 2014 00:40:33 +0100 Subject: [PATCH] Completion pattern update --- qutebrowser/models/settingcompletion.py | 83 +++++++++++++------------ qutebrowser/widgets/completion.py | 6 +- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/qutebrowser/models/settingcompletion.py b/qutebrowser/models/settingcompletion.py index caa59fb7d..2925d550f 100644 --- a/qutebrowser/models/settingcompletion.py +++ b/qutebrowser/models/settingcompletion.py @@ -1,40 +1,43 @@ -# Copyright 2014 Florian Bruhin (The Compiler) -# -# This file is part of qutebrowser. -# -# qutebrowser is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# qutebrowser is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with qutebrowser. If not, see . - -"""A CompletionModel filled with settings and their descriptions.""" - -from collections import OrderedDict - -from qutebrowser.models.completion import CompletionModel -from qutebrowser.config.configdata import configdata - - -class SettingCompletionModel(CompletionModel): - - """A CompletionModel filled with settings and their descriptions.""" - - # pylint: disable=abstract-method - - def __init__(self, parent=None): - super().__init__(parent) - data = OrderedDict() - for secname, secdata in configdata().items(): - newdata = [] - for name in secdata.values.keys(): - newdata.append((name, secdata.descriptions[name])) - data[secname] = newdata - self.init_data(data) +# Copyright 2014 Florian Bruhin (The Compiler) +# +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see . + +"""A CompletionModel filled with settings and their descriptions.""" + +import logging + +from collections import OrderedDict + +from qutebrowser.models.completion import CompletionModel +from qutebrowser.config.configdata import configdata + + +class SettingCompletionModel(CompletionModel): + + """A CompletionModel filled with settings and their descriptions.""" + + # pylint: disable=abstract-method + + def __init__(self, parent=None): + super().__init__(parent) + data = OrderedDict() + for secname, secdata in configdata().items(): + newdata = [] + for name in secdata.values.keys(): + newdata.append((name, secdata.descriptions[name])) + data[secname] = newdata + logging.debug("Setting data: {}".format(data)) + self.init_data(data) diff --git a/qutebrowser/widgets/completion.py b/qutebrowser/widgets/completion.py index 41e120206..c8429d85d 100644 --- a/qutebrowser/widgets/completion.py +++ b/qutebrowser/widgets/completion.py @@ -22,6 +22,7 @@ subclasses to provide completions. """ +import logging import html from PyQt5.QtWidgets import (QStyle, QStyleOptionViewItem, QTreeView, @@ -200,8 +201,11 @@ class CompletionView(QTreeView): self.setmodel('command') self._completing = True - if text: + if text.endswith(' '): + text = '' + elif text: text = text.split()[-1] + logging.debug("pattern: {}".format(text)) self.model.pattern = text self.model.sourceModel().mark_all_items(text) if self._enabled: