Stop history browsing at the correct places.

This commit is contained in:
Florian Bruhin 2014-08-13 07:10:24 +02:00
parent 9c69ea3c45
commit 47e405dda5
2 changed files with 8 additions and 0 deletions

View File

@ -64,6 +64,7 @@ class ConsoleLineEdit(CommandLineEdit):
@pyqtSlot(str)
def execute(self):
"""Execute the line of code which was entered."""
self.history.stop()
text = self.text()
self.history.append(text)
self.push(text)

View File

@ -19,6 +19,7 @@
"""Misc. widgets used at different places."""
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QLineEdit
from PyQt5.QtGui import QValidator
@ -61,6 +62,12 @@ class CommandLineEdit(QLineEdit):
self.history = History()
self._validator = _CommandValidator(validator, parent=self)
self.setValidator(self._validator)
self.textEdited.connect(self.on_text_edited)
@pyqtSlot(str)
def on_text_edited(self, _text):
"""Slot for textEdited. Stop history browsing."""
self.history.stop()
def __repr__(self):
return '<{} "{}">'.format(self.__class__.__name__, self.text())