Skip to content

Commit

Permalink
Fix broken logic in clearing python console history
Browse files Browse the repository at this point in the history
- clearing session was also clearing the file history
- clearing file history was doing nothing
  • Loading branch information
nyalldawson committed Oct 11, 2022
1 parent 3c4ccab commit 34227bd
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions python/console/console_sci.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,17 @@ def readHistoryFile(self):
def clearHistory(self, clearSession=False):
if clearSession:
self.history = []
self.readHistoryFile()
self.syncSoftHistory()
msgText = QCoreApplication.translate('PythonConsole',
'Session and file history cleared successfully.')
'Session history cleared successfully.')
self.parent.callWidgetMessageBar(msgText)
return
ok = False
try:
cH = codecs.open(_historyFile, 'w', encoding='utf-8')
ok = True
except:
raise
cH.close()
if ok:
else:
self.history = []
if QFile.exists(_historyFile):
with open(_historyFile, 'w', encoding='utf-8') as h:
h.truncate()

msgText = QCoreApplication.translate('PythonConsole',
'History cleared successfully.')
self.parent.callWidgetMessageBar(msgText)
Expand Down

0 comments on commit 34227bd

Please sign in to comment.