summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2018-05-03 13:58:26 +0200
committerFlorian Bruhin <git@the-compiler.org>2018-05-03 13:58:26 +0200
commit49bdcd5a972f28e0f45e09b63a1102d44cbabe10 (patch)
treea756226f84d862a1ee34cd845a6856e6ae540e71
parent106e591a36ec1f7d6e3e1aade373e2b18980e5db (diff)
parent1d2dd5bf55ec42f0fec92634a9472432c3342853 (diff)
downloadqutebrowser-49bdcd5a972f28e0f45e09b63a1102d44cbabe10.tar.gz
qutebrowser-49bdcd5a972f28e0f45e09b63a1102d44cbabe10.zip
Merge remote-tracking branch 'origin/pr/3796'
-rw-r--r--qutebrowser/mainwindow/statusbar/command.py31
-rw-r--r--tests/end2end/data/search.html2
-rw-r--r--tests/end2end/features/search.feature17
3 files changed, 36 insertions, 14 deletions
diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py
index 681e20ac5..61b9fb43a 100644
--- a/qutebrowser/mainwindow/statusbar/command.py
+++ b/qutebrowser/mainwindow/statusbar/command.py
@@ -19,6 +19,8 @@
"""The commandline in the statusbar."""
+import functools
+
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QSize
from PyQt5.QtWidgets import QSizePolicy
@@ -69,6 +71,14 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
self.textChanged.connect(self.updateGeometry)
self.textChanged.connect(self._incremental_search)
+ dispatcher = objreg.get('command-dispatcher',
+ scope='window', window=self._win_id)
+ search_fn = dispatcher.search
+ self.search_prefixes = {
+ '/': search_fn,
+ '?': functools.partial(search_fn, reverse=True)
+ }
+
def prefix(self):
"""Get the currently entered command prefix."""
text = self.text()
@@ -162,17 +172,17 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
Args:
rapid: Run the command without closing or clearing the command bar.
"""
- prefixes = {
- ':': '',
- '/': 'search -- ',
- '?': 'search -r -- ',
- }
text = self.text()
self.history.append(text)
if not rapid:
modeman.leave(self._win_id, usertypes.KeyMode.command,
'cmd accept')
- self.got_cmd[str].emit(prefixes[text[0]] + text[1:])
+
+ prefix = text[0]
+ if prefix in self.search_prefixes:
+ self.search_prefixes[prefix](text[1:])
+ else:
+ self.got_cmd[str].emit(text[1:])
@cmdutils.register(instance='status-command', scope='window')
def edit_command(self, run=False):
@@ -258,10 +268,5 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
if not config.val.search.incremental:
return
- search_prefixes = {
- '/': 'search -- ',
- '?': 'search -r -- ',
- }
-
- if self.prefix() in ['/', '?']:
- self.got_cmd[str].emit(search_prefixes[text[0]] + text[1:])
+ if self.prefix() in self.search_prefixes:
+ self.search_prefixes[self.prefix()](text[1:])
diff --git a/tests/end2end/data/search.html b/tests/end2end/data/search.html
index 003751cfd..1064a7d01 100644
--- a/tests/end2end/data/search.html
+++ b/tests/end2end/data/search.html
@@ -16,6 +16,8 @@
BAZ<br/>
space travel<br/>
/slash<br/>
+ -r reversed<br/>
+ ;; semicolons<br/>
<a class="toselect" href="hello.txt">follow me!</a><br/>
</p>
</body>
diff --git a/tests/end2end/features/search.feature b/tests/end2end/features/search.feature
index 1374b4e10..568831c0d 100644
--- a/tests/end2end/features/search.feature
+++ b/tests/end2end/features/search.feature
@@ -40,11 +40,26 @@ Feature: Searching on a page
Then "space " should be found
Scenario: Searching with / and slash in search term (issue 507)
- When I run :set-cmd-text -s //slash
+ When I run :set-cmd-text //slash
And I run :command-accept
And I wait for "search found /slash" in the log
Then "/slash" should be found
+ Scenario: Searching with arguments at start of search term
+ When I run :set-cmd-text /-r reversed
+ And I run :command-accept
+ And I wait for "search found -r reversed" in the log
+ Then "-r reversed" should be found
+
+ Scenario: Searching with semicolons in search term
+ When I run :set-cmd-text /;
+ And I run :fake-key -g ;
+ And I run :fake-key -g <space>
+ And I run :fake-key -g semi
+ And I run :command-accept
+ And I wait for "search found ;; semi" in the log
+ Then ";; semi" should be found
+
# This doesn't work because this is QtWebKit behavior.
@xfail_norun
Scenario: Searching text with umlauts