Permalink
Browse files

Remove general -> wrap-search

  • Loading branch information...
The-Compiler committed Jul 12, 2016
1 parent f0da508 commit 64b32ec87d739b3df7119c7857e8dbe38429139b
View
@@ -46,6 +46,10 @@ Removed
- The ability to display status messages from webpages, as well as the related
`ui -> display-statusbar-messages` setting.
- The `general -> wrap-search` setting as searches now always wrap.
According to a quick straw poll and prior crash logs, almost nobody is using
`wrap-search = false`, and turning off wrapping is not possible with
QtWebEngine.
Fixed
-----
@@ -142,14 +142,13 @@ def __init__(self, parent=None):
self._widget = None
self.text = None
def search(self, text, *, ignore_case=False, wrap=False, reverse=False,
def search(self, text, *, ignore_case=False, reverse=False,
result_cb=None):
"""Find the given text on the page.
Args:
text: The text to search for.
ignore_case: Search case-insensitively. (True/False/'smart')
wrap: Wrap around to the top when arriving at the bottom.
reverse: Reverse search direction.
result_cb: Called with a bool indicating whether a match was found.
"""
@@ -1466,20 +1466,8 @@ def _search_cb(self, found, *, tab, old_scroll_pos, options, text, prev):
message.info(self._win_id, "Search hit TOP, continuing at "
"BOTTOM", immediately=True)
else:
# User disabled wrapping; but findText() just returns False. If we
# have a selection, we know there's a match *somewhere* on the page
if not options['wrap'] and tab.caret.has_selection():
if going_up:
message.warning(self._win_id, "Search hit TOP without "
"match for: {}".format(text),
immediately=True)
else:
message.warning(self._win_id, "Search hit BOTTOM without "
"match for: {}".format(text),
immediately=True)
else:
message.warning(self._win_id, "Text '{}' not found on "
"page!".format(text), immediately=True)
message.warning(self._win_id, "Text '{}' not found on "
"page!".format(text), immediately=True)
@cmdutils.register(instance='command-dispatcher', scope='window',
maxsplit=0)
@@ -1496,7 +1484,6 @@ def search(self, text="", reverse=False):
options = {
'ignore_case': config.get('general', 'ignore-case'),
'wrap': config.get('general', 'wrap-search'),
'reverse': reverse,
}
self._tabbed_browser.search_text = text
@@ -72,7 +72,7 @@ def _find(self, text, flags, cb=None):
else:
self._widget.findText(text, flags, cb)
def search(self, text, *, ignore_case=False, wrap=False, reverse=False,
def search(self, text, *, ignore_case=False, reverse=False,
result_cb=None):
flags = QWebEnginePage.FindFlags(0)
if ignore_case == 'smart':
@@ -85,16 +85,14 @@ def clear(self):
self._widget.findText('')
self._widget.findText('', QWebPage.HighlightAllOccurrences)
def search(self, text, *, ignore_case=False, wrap=False, reverse=False,
def search(self, text, *, ignore_case=False, reverse=False,
result_cb=None):
flags = QWebPage.FindFlags(0)
if ignore_case == 'smart':
if not text.islower():
flags |= QWebPage.FindCaseSensitively
elif not ignore_case:
flags |= QWebPage.FindCaseSensitively
if wrap:
flags |= QWebPage.FindWrapsAroundDocument
if reverse:
flags |= QWebPage.FindBackward
# We actually search *twice* - once to highlight everything, then again
@@ -352,6 +352,7 @@ class ConfigManager(QObject):
('tabs', 'auto-hide'),
('tabs', 'hide-always'),
('ui', 'display-statusbar-messages'),
('general', 'wrap-search'),
]
CHANGED_OPTIONS = {
('content', 'cookies-accept'):
@@ -134,11 +134,6 @@ def data(readonly=False):
SettingValue(typ.IgnoreCase(), 'smart'),
"Whether to find text on a page case-insensitively."),
('wrap-search',
SettingValue(typ.Bool(), 'true'),
"Whether to wrap finding text to the top when arriving at the "
"end."),
('startpage',
SettingValue(typ.List(), 'https://duckduckgo.com'),
"The default page(s) to open at the start, separated by commas."),
@@ -146,42 +146,18 @@ Feature: Searching on a page
## wrapping
Scenario: Wrapping around page
When I set general -> wrap-search to true
And I run :search foo
When I run :search foo
And I run :search-next
And I run :search-next
And I run :yank-selected
Then the clipboard should contain "foo"
Scenario: Wrapping around page with wrap-search = false
When I set general -> wrap-search to false
And I run :search foo
And I run :search-next
And I run :search-next
Then the warning "Search hit BOTTOM without match for: foo" should be shown
Scenario: Wrapping around page with --reverse
When I set general -> wrap-search to true
And I run :search --reverse foo
When I run :search --reverse foo
And I run :search-next
And I run :search-next
And I run :yank-selected
Then the clipboard should contain "Foo"
Scenario: Wrapping around page with wrap-search = false and --reverse
When I set general -> wrap-search to false
And I run :search --reverse foo
And I run :search-next
And I run :search-next
Then the warning "Search hit TOP without match for: foo" should be shown
Scenario: Wrapping around page
When I set general -> wrap-search to true
And I run :search foo
And I run :search-next
And I run :search-next
And I run :yank-selected
Then the clipboard should contain "foo"
# TODO: wrapping message with scrolling
# TODO: wrapping message without scrolling

0 comments on commit 64b32ec

Please sign in to comment.