-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR: Limit the number of lines in history according to the relevant setting #7132
Changes from 1 commit
3c12105
922e0f7
788993f
b58c529
0c4b215
a777927
12e8cd3
2a39855
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
# Standard library imports | ||
import os.path as osp | ||
import sys | ||
import re | ||
|
||
# Third party imports | ||
from qtpy import PYQT5 | ||
|
@@ -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): | ||
|
@@ -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)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to convert all EOL's to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we just always use LF for our own history files, independent of the platform? |
||
maxNline = CONF.get('historylog', 'max_entries') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plugins can access config their own options like this
|
||
if len(linebreak) > maxNline: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where all the tests are failing--it should be |
||
text = text[linebreaks[-maxNline] +1:] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespace around + |
||
encoding.write(text, filename) | ||
editor.set_text(text) | ||
editor.set_cursor_position('eof') | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this. It's not needed.