Update incremental_search PR with changes from review
This commit is contained in:
parent
77054cc063
commit
bb2fcddcd4
@ -1750,7 +1750,7 @@ class CommandDispatcher:
|
|||||||
message.info("Search hit TOP, continuing at BOTTOM")
|
message.info("Search hit TOP, continuing at BOTTOM")
|
||||||
else:
|
else:
|
||||||
message.warning("Text '{}' not found on page!".format(text),
|
message.warning("Text '{}' not found on page!".format(text),
|
||||||
replace=True)
|
replace=True)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||||
maxsplit=0)
|
maxsplit=0)
|
||||||
|
@ -45,7 +45,7 @@ ignore_case:
|
|||||||
|
|
||||||
incremental_search:
|
incremental_search:
|
||||||
type: Bool
|
type: Bool
|
||||||
default: False
|
default: True
|
||||||
desc: Find text on a page incrementally, renewing the search for each typing character.
|
desc: Find text on a page incrementally, renewing the search for each typing character.
|
||||||
|
|
||||||
new_instance_open_target:
|
new_instance_open_target:
|
||||||
|
@ -46,7 +46,6 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
update_completion: Emitted when the completion should be shown/updated.
|
update_completion: Emitted when the completion should be shown/updated.
|
||||||
show_cmd: Emitted when command input should be shown.
|
show_cmd: Emitted when command input should be shown.
|
||||||
hide_cmd: Emitted when command input can be hidden.
|
hide_cmd: Emitted when command input can be hidden.
|
||||||
update_search: Emitted when search term could be updated.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
got_cmd = pyqtSignal([str], [str, int])
|
got_cmd = pyqtSignal([str], [str, int])
|
||||||
@ -55,7 +54,6 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
update_completion = pyqtSignal()
|
update_completion = pyqtSignal()
|
||||||
show_cmd = pyqtSignal()
|
show_cmd = pyqtSignal()
|
||||||
hide_cmd = pyqtSignal()
|
hide_cmd = pyqtSignal()
|
||||||
update_search = pyqtSignal()
|
|
||||||
|
|
||||||
def __init__(self, *, win_id, private, parent=None):
|
def __init__(self, *, win_id, private, parent=None):
|
||||||
misc.CommandLineEdit.__init__(self, parent=parent)
|
misc.CommandLineEdit.__init__(self, parent=parent)
|
||||||
@ -69,8 +67,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
self.cursorPositionChanged.connect(self.update_completion)
|
self.cursorPositionChanged.connect(self.update_completion)
|
||||||
self.textChanged.connect(self.update_completion)
|
self.textChanged.connect(self.update_completion)
|
||||||
self.textChanged.connect(self.updateGeometry)
|
self.textChanged.connect(self.updateGeometry)
|
||||||
self.textChanged.connect(self.update_search)
|
self.textChanged.connect(self._incremental_search)
|
||||||
self.update_search.connect(self.incrementSearch)
|
|
||||||
|
|
||||||
def prefix(self):
|
def prefix(self):
|
||||||
"""Get the currently entered command prefix."""
|
"""Get the currently entered command prefix."""
|
||||||
@ -244,12 +241,14 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
width = self.fontMetrics().width(text)
|
width = self.fontMetrics().width(text)
|
||||||
return QSize(width, height)
|
return QSize(width, height)
|
||||||
|
|
||||||
def incrementSearch(self):
|
@pyqtSlot(str)
|
||||||
if config.val.incremental_search == True:
|
def _incremental_search(self, text):
|
||||||
|
if config.val.incremental_search:
|
||||||
search_prefixes = {
|
search_prefixes = {
|
||||||
'/': 'search -- ',
|
'/': 'search -- ',
|
||||||
'?': 'search -r -- ',
|
'?': 'search -r -- ',
|
||||||
}
|
}
|
||||||
if self.prefix() == '/' or self.prefix() == '?':
|
|
||||||
text = self.text()
|
# len(text) check is for when user presses <Esc>
|
||||||
|
if self.prefix() in '/?' and len(text) != 0:
|
||||||
self.got_cmd[str].emit(search_prefixes[text[0]] + text[1:])
|
self.got_cmd[str].emit(search_prefixes[text[0]] + text[1:])
|
||||||
|
Loading…
Reference in New Issue
Block a user