Call search command directly instead of using arguments
This commit is contained in:
parent
76dbfa7305
commit
646e92707a
@ -1778,16 +1778,14 @@ class CommandDispatcher:
|
|||||||
replace=True)
|
replace=True)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||||
maxsplit=0, star_args_optional=True, no_cmd_split=True)
|
maxsplit=0)
|
||||||
def search(self, *text, reverse=False):
|
def search(self, text="", reverse=False):
|
||||||
"""Search for a text on the current page. With no text, clear results.
|
"""Search for a text on the current page. With no text, clear results.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
text: The text to search for.
|
text: The text to search for.
|
||||||
reverse: Reverse search direction.
|
reverse: Reverse search direction.
|
||||||
"""
|
"""
|
||||||
text = ' '.join(text)
|
|
||||||
|
|
||||||
self.set_mark("'")
|
self.set_mark("'")
|
||||||
tab = self._current_widget()
|
tab = self._current_widget()
|
||||||
|
|
||||||
|
@ -69,6 +69,13 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
self.textChanged.connect(self.updateGeometry)
|
self.textChanged.connect(self.updateGeometry)
|
||||||
self.textChanged.connect(self._incremental_search)
|
self.textChanged.connect(self._incremental_search)
|
||||||
|
|
||||||
|
search_fn = cmdutils.cmd_dict['search'].run
|
||||||
|
self.search_prefixes = {
|
||||||
|
'/': lambda search: search_fn(self._win_id, ["--", search]),
|
||||||
|
'?': lambda search: search_fn(self._win_id, ["-r", "--", search]),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def prefix(self):
|
def prefix(self):
|
||||||
"""Get the currently entered command prefix."""
|
"""Get the currently entered command prefix."""
|
||||||
text = self.text()
|
text = self.text()
|
||||||
@ -162,17 +169,17 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
Args:
|
Args:
|
||||||
rapid: Run the command without closing or clearing the command bar.
|
rapid: Run the command without closing or clearing the command bar.
|
||||||
"""
|
"""
|
||||||
prefixes = {
|
|
||||||
':': '',
|
|
||||||
'/': 'search -- ',
|
|
||||||
'?': 'search -r -- ',
|
|
||||||
}
|
|
||||||
text = self.text()
|
text = self.text()
|
||||||
self.history.append(text)
|
self.history.append(text)
|
||||||
if not rapid:
|
if not rapid:
|
||||||
modeman.leave(self._win_id, usertypes.KeyMode.command,
|
modeman.leave(self._win_id, usertypes.KeyMode.command,
|
||||||
'cmd accept')
|
'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')
|
@cmdutils.register(instance='status-command', scope='window')
|
||||||
def edit_command(self, run=False):
|
def edit_command(self, run=False):
|
||||||
@ -258,10 +265,5 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
if not config.val.search.incremental:
|
if not config.val.search.incremental:
|
||||||
return
|
return
|
||||||
|
|
||||||
search_prefixes = {
|
if self.prefix() in self.search_prefixes:
|
||||||
'/': 'search -- ',
|
self.search_prefixes[self.prefix()](text[1:])
|
||||||
'?': 'search -r -- ',
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.prefix() in ['/', '?']:
|
|
||||||
self.got_cmd[str].emit(search_prefixes[text[0]] + text[1:])
|
|
||||||
|
Loading…
Reference in New Issue
Block a user