Merge remote-tracking branch 'origin/pr/3796'
This commit is contained in:
commit
49bdcd5a97
@ -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:])
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user