Skip to content

Commit

Permalink
Fixes #7080
Browse files Browse the repository at this point in the history
A better thing would be to read the history from ipython, but I am not sure that this would work in every cases.
  • Loading branch information
impact27 authored May 15, 2018
1 parent b293dc1 commit 3c12105
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spyder/plugins/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Standard library imports
import os.path as osp
import sys
import re

# Third party imports
from qtpy import PYQT5
Expand All @@ -29,6 +30,7 @@
from spyder.widgets.tabs import Tabs
from spyder.widgets.sourcecode import codeeditor
from spyder.widgets.findreplace import FindReplace
from spyder.config.main import CONF


class HistoryConfigPage(PluginConfigPage):
Expand Down Expand Up @@ -230,6 +232,11 @@ def add_history(self, filename):
editor.toggle_wrap_mode( self.get_option('wrap') )

text, _ = encoding.read(filename)
linebreaks = [m.start() for m in re.finditer('\n', text)]
maxNline = CONF.get('historylog', 'max_entries')
if len(linebreak) > maxNline:
text = text[linebreaks[-maxNline] +1:]
encoding.write(text, filename)
editor.set_text(text)
editor.set_cursor_position('eof')

Expand Down

0 comments on commit 3c12105

Please sign in to comment.