From f907b6b6b01604cc206323b775d549c6ba791f25 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sun, 30 Apr 2017 00:21:22 +0200 Subject: [PATCH] Have an isolated command history for private windows --- qutebrowser/mainwindow/statusbar/command.py | 9 +++++---- qutebrowser/misc/cmdhistory.py | 6 +----- qutebrowser/misc/miscwidgets.py | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py index 410e578c9..3647d9859 100644 --- a/qutebrowser/mainwindow/statusbar/command.py +++ b/qutebrowser/mainwindow/statusbar/command.py @@ -55,12 +55,13 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): hide_cmd = pyqtSignal() def __init__(self, *, win_id, private, parent=None): - misc.CommandLineEdit.__init__(self, private=private, parent=parent) + misc.CommandLineEdit.__init__(self, parent=parent) misc.MinimalLineEditMixin.__init__(self) self._win_id = win_id - command_history = objreg.get('command-history') - self.history.history = command_history.data - self.history.changed.connect(command_history.changed) + if not private: + command_history = objreg.get('command-history') + self.history.history = command_history.data + self.history.changed.connect(command_history.changed) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored) self.cursorPositionChanged.connect(self.update_completion) self.textChanged.connect(self.update_completion) diff --git a/qutebrowser/misc/cmdhistory.py b/qutebrowser/misc/cmdhistory.py index cb60c84f6..baf210a68 100644 --- a/qutebrowser/misc/cmdhistory.py +++ b/qutebrowser/misc/cmdhistory.py @@ -45,7 +45,6 @@ class History(QObject): Attributes: history: A list of executed commands, with newer commands at the end. _tmphist: Temporary history for history browsing (as NeighborList) - _private: Whether this history is in private browsing mode. Signals: changed: Emitted when an entry was added to the history. @@ -53,7 +52,7 @@ class History(QObject): changed = pyqtSignal() - def __init__(self, *, private=False, history=None, parent=None): + def __init__(self, *, history=None, parent=None): """Constructor. Args: @@ -61,7 +60,6 @@ class History(QObject): """ super().__init__(parent) self._tmphist = None - self._private = private if history is None: self.history = [] else: @@ -128,8 +126,6 @@ class History(QObject): Args: text: The text to append. """ - if self._private: - return if not self.history or text != self.history[-1]: self.history.append(text) self.changed.emit() diff --git a/qutebrowser/misc/miscwidgets.py b/qutebrowser/misc/miscwidgets.py index 75f941fd8..b4a17e638 100644 --- a/qutebrowser/misc/miscwidgets.py +++ b/qutebrowser/misc/miscwidgets.py @@ -69,9 +69,9 @@ class CommandLineEdit(QLineEdit): _promptlen: The length of the current prompt. """ - def __init__(self, *, private=False, parent=None): + def __init__(self, *, parent=None): super().__init__(parent) - self.history = cmdhistory.History(private=private, parent=self) + self.history = cmdhistory.History(parent=self) self._validator = _CommandValidator(self) self.setValidator(self._validator) self.textEdited.connect(self.on_text_edited)