-
-
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
Conversation
A better thing would be to read the history from ipython, but I am not sure that this would work in every cases.
Hello @impact27! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on June 15, 2018 at 22:19 Hours UTC |
spyder/plugins/history.py
Outdated
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:] |
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.
Whitespace around +
Thanks for doing this! I need to head to work now, but a few quick things:
|
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.
Appears to be a typo bug causing all the tests to fail. I'll actually test this later once you've fixed your bug, etc, but please describe what this is intended to do and how so I can most easily evaluate it. Thanks!
spyder/plugins/history.py
Outdated
@@ -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: |
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.
This is where all the tests are failing--it should be linebreaks
presumably. Easy mistake to make, but one a basic code checker or a simple test (unit test or just actually testing that the functionality worked without error) would have caught.
spyder/plugins/history.py
Outdated
@@ -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 |
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.
spyder/plugins/history.py
Outdated
@@ -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') |
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.
Plugins can access config their own options like this
maxNline = self.get_option('max_entries')
Things look good, I just left a minor comment. |
@ccordoba12 Do we want a regression test for this to ensure the change is and remains effective? |
A test would be nice, yes, but it doesn't seem easy to implement. Besides, the code looks good. |
Well, those are some famous last words if I ever heard some, heh... :) |
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.
I made myself the changes I requested. They were very simple.
spyder/plugins/history.py
Outdated
@@ -230,6 +231,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 comment
The reason will be displayed to describe this comment to others. Learn more.
We need to convert all EOL's to \n
before doing this.
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.
Can't we just always use LF for our own history files, independent of the platform?
Pull Request Checklist
modified the
spyder/defaults
directory, or added new icons/assetsIncluded a screenshot, if this PR makes any visible changes to the UIDescription of Changes
A better thing would be to read the history from ipython, but I am not sure that this would work in every cases.
Issue(s) Resolved
Fixes #7080