diff options
author | Florian Bruhin <me@the-compiler.org> | 2022-06-14 10:05:14 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2022-06-14 10:23:15 +0200 |
commit | 8137f2a6d90e30643ad3bcf0c2c182c9a48012eb (patch) | |
tree | 172e4523fbc010c5fcaa0c408c67a92602033337 | |
parent | 77269f789addcc2f73b9eb2d53eb429090a9cd7d (diff) | |
download | qutebrowser-8137f2a6d90e30643ad3bcf0c2c182c9a48012eb.tar.gz qutebrowser-8137f2a6d90e30643ad3bcf0c2c182c9a48012eb.zip |
Add a SearchMatch.is_null()
-rw-r--r-- | qutebrowser/browser/browsertab.py | 4 | ||||
-rw-r--r-- | qutebrowser/mainwindow/statusbar/searchmatch.py | 13 |
2 files changed, 8 insertions, 9 deletions
diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index ca6a9c483..e87ac806e 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -310,6 +310,10 @@ class SearchMatch: self.current = 0 self.total = 0 + def is_null(self) -> bool: + """Whether the SearchMatch is set to zero.""" + return self.current == 0 and self.total == 0 + def at_limit(self, going_up: bool) -> bool: """Whether the SearchMatch is currently at the first/last result.""" return ( diff --git a/qutebrowser/mainwindow/statusbar/searchmatch.py b/qutebrowser/mainwindow/statusbar/searchmatch.py index da337b19a..6d0b86007 100644 --- a/qutebrowser/mainwindow/statusbar/searchmatch.py +++ b/qutebrowser/mainwindow/statusbar/searchmatch.py @@ -22,7 +22,6 @@ from PyQt5.QtCore import pyqtSlot -from qutebrowser.utils import log from qutebrowser.browser import browsertab from qutebrowser.mainwindow.statusbar import textbase @@ -32,17 +31,13 @@ class SearchMatch(textbase.TextBase): """The part of the statusbar that displays the search match counter.""" @pyqtSlot(browsertab.SearchMatch) - def set_match(self, match: browsertab.SearchMatch) -> None: + def set_match(self, search_match: browsertab.SearchMatch) -> None: """Set the match counts in the statusbar. Passing SearchMatch(0, 0) hides the match counter. Args: - match: The currently active search match. + search_match: The currently active search match. """ - if match.current <= 0 and match.total <= 0: - self.setText('') - log.statusbar.debug('Clearing search match text.') - else: - self.setText(f'Match [{match}]') - log.statusbar.debug(f'Setting search match text to {match}') + text = '' if search_match.is_null() else f'Match [{search_match}]' + self.setText(text) |