From bb2fcddcd44d818ea30daa59bb9d9dacf506d669 Mon Sep 17 00:00:00 2001 From: Justin Partain Date: Thu, 26 Oct 2017 10:17:40 -0400 Subject: [PATCH] Update incremental_search PR with changes from review --- qutebrowser/browser/commands.py | 2 +- qutebrowser/config/configdata.yml | 2 +- qutebrowser/mainwindow/statusbar/command.py | 15 +++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 8ba3a6f35..c85302c46 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1750,7 +1750,7 @@ class CommandDispatcher: message.info("Search hit TOP, continuing at BOTTOM") else: message.warning("Text '{}' not found on page!".format(text), - replace=True) + replace=True) @cmdutils.register(instance='command-dispatcher', scope='window', maxsplit=0) diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 4843ad7c8..58d3ea0d7 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -45,7 +45,7 @@ ignore_case: incremental_search: type: Bool - default: False + default: True desc: Find text on a page incrementally, renewing the search for each typing character. new_instance_open_target: diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py index 1a42001c4..106c2597f 100644 --- a/qutebrowser/mainwindow/statusbar/command.py +++ b/qutebrowser/mainwindow/statusbar/command.py @@ -46,7 +46,6 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): update_completion: Emitted when the completion should be shown/updated. show_cmd: Emitted when command input should be shown. hide_cmd: Emitted when command input can be hidden. - update_search: Emitted when search term could be updated. """ got_cmd = pyqtSignal([str], [str, int]) @@ -55,7 +54,6 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): update_completion = pyqtSignal() show_cmd = pyqtSignal() hide_cmd = pyqtSignal() - update_search = pyqtSignal() def __init__(self, *, win_id, private, parent=None): misc.CommandLineEdit.__init__(self, parent=parent) @@ -69,8 +67,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): self.cursorPositionChanged.connect(self.update_completion) self.textChanged.connect(self.update_completion) self.textChanged.connect(self.updateGeometry) - self.textChanged.connect(self.update_search) - self.update_search.connect(self.incrementSearch) + self.textChanged.connect(self._incremental_search) def prefix(self): """Get the currently entered command prefix.""" @@ -244,12 +241,14 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): width = self.fontMetrics().width(text) return QSize(width, height) - def incrementSearch(self): - if config.val.incremental_search == True: + @pyqtSlot(str) + def _incremental_search(self, text): + if config.val.incremental_search: search_prefixes = { '/': 'search -- ', '?': 'search -r -- ', } - if self.prefix() == '/' or self.prefix() == '?': - text = self.text() + + # len(text) check is for when user presses + if self.prefix() in '/?' and len(text) != 0: self.got_cmd[str].emit(search_prefixes[text[0]] + text[1:])