diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 924d2bbe1..ff1a4aa52 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -40,6 +40,7 @@ Changed - When yanking a mailto: link via hints, the mailto: prefix is now stripped - Zoom level messages are now not stacked on top of each other anymore. - qutebrowser now automatically uses QtWebEngine if QtWebKit is unavailable +- :history-clear now asks for a confirmation, unless it's run with --force. Fixed ----- diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index d6db9f350..03345ac64 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -420,10 +420,15 @@ Start hinting. [[history-clear]] === history-clear +Syntax: +:history-clear [*--force*]+ + Clear all browsing history. Note this only clears the global history (e.g. `~/.local/share/qutebrowser/history` on Linux) but not cookies, the back/forward history of a tab, cache or other persistent data. +==== optional arguments +* +*-f*+, +*--force*+: Don't ask for confirmation. + [[home]] === home Open main startpage in current tab. diff --git a/qutebrowser/browser/history.py b/qutebrowser/browser/history.py index e4288f891..2615fd393 100644 --- a/qutebrowser/browser/history.py +++ b/qutebrowser/browser/history.py @@ -26,7 +26,7 @@ from PyQt5.QtCore import pyqtSignal, pyqtSlot, QUrl, QObject from qutebrowser.commands import cmdutils from qutebrowser.utils import (utils, objreg, standarddir, log, qtutils, - usertypes) + usertypes, message) from qutebrowser.config import config from qutebrowser.misc import lineparser, objects @@ -230,13 +230,23 @@ class WebHistory(QObject): self._saved_count = len(self._new_history) @cmdutils.register(name='history-clear', instance='web-history') - def clear(self): + def clear(self, force=False): """Clear all browsing history. Note this only clears the global history (e.g. `~/.local/share/qutebrowser/history` on Linux) but not cookies, the back/forward history of a tab, cache or other persistent data. + + Args: + force: Don't ask for confirmation. """ + if force: + self._do_clear() + else: + message.confirm_async(self._do_clear, title="Clear all browsing " + "history?") + + def _do_clear(self): self._lineparser.clear() self.history_dict.clear() self._temp_history.clear() diff --git a/tests/end2end/features/history.feature b/tests/end2end/features/history.feature index 3c35ad03f..decd71dd9 100644 --- a/tests/end2end/features/history.feature +++ b/tests/end2end/features/history.feature @@ -4,7 +4,7 @@ Feature: Page history Background: Given I open about:blank - And I run :history-clear + And I run :history-clear --force Scenario: Simple history saving When I open data/numbers/1.txt @@ -56,8 +56,15 @@ Feature: Page history Then "Changing title for idx 1 to 'about:blank'" should be logged Scenario: Clearing history + When I open data/title.html + And I run :history-clear --force + Then the history file should be empty + + Scenario: Clearing history with confirmation When I open data/title.html And I run :history-clear + And I wait for "Asking question <* title='Clear all browsing history?'>, *" in the log + And I run :prompt-accept yes Then the history file should be empty Scenario: History with yanked URL and 'add to history' flag