Don't record command history in private mode.

Fixes #43.
This commit is contained in:
Florian Bruhin 2014-12-10 13:19:42 +01:00
parent 76c5c8bf8e
commit b30ca6bcb6
2 changed files with 7 additions and 0 deletions

View File

@ -21,6 +21,7 @@
from PyQt5.QtCore import pyqtSlot from PyQt5.QtCore import pyqtSlot
from qutebrowser.config import config
from qutebrowser.utils import usertypes, log from qutebrowser.utils import usertypes, log
@ -43,6 +44,7 @@ class History:
"""Command history. """Command history.
Attributes: Attributes:
handle_private_mode: Whether to ignore history in private mode.
history: A list of executed commands, with newer commands at the end. history: A list of executed commands, with newer commands at the end.
_tmphist: Temporary history for history browsing (as NeighborList) _tmphist: Temporary history for history browsing (as NeighborList)
""" """
@ -53,6 +55,7 @@ class History:
Args: Args:
history: The initial history to set. history: The initial history to set.
""" """
self.handle_private_mode = False
self._tmphist = None self._tmphist = None
if history is None: if history is None:
self.history = [] self.history = []
@ -120,5 +123,8 @@ class History:
Args: Args:
text: The text to append. text: The text to append.
""" """
if (self.handle_private_mode and
config.get('general', 'private-browsing')):
return
if not self.history or text != self.history[-1]: if not self.history or text != self.history[-1]:
self.history.append(text) self.history.append(text)

View File

@ -64,6 +64,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
misc.CommandLineEdit.__init__(self, parent) misc.CommandLineEdit.__init__(self, parent)
misc.MinimalLineEditMixin.__init__(self) misc.MinimalLineEditMixin.__init__(self)
self._win_id = win_id self._win_id = win_id
self.history.handle_private_mode = True
self.history.history = objreg.get('command-history').data self.history.history = objreg.get('command-history').data
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored)
self.cursorPositionChanged.connect(self.update_completion) self.cursorPositionChanged.connect(self.update_completion)