From 8137f2a6d90e30643ad3bcf0c2c182c9a48012eb Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 14 Jun 2022 10:05:14 +0200 Subject: Add a SearchMatch.is_null() --- qutebrowser/browser/browsertab.py | 4 ++++ 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) -- cgit v1.2.3-54-g00ecf