Skip to content
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

Merged
merged 8 commits into from
Jun 15, 2018

Conversation

impact27
Copy link
Contributor

@impact27 impact27 commented May 15, 2018

Pull Request Checklist

  • Read and followed this repo's Contributing Guidelines
  • Based your PR on the latest version of the correct branch (master or 3.x)
  • Followed PEP8 for code style
  • Ensured your pull request hasn't eliminated unrelated blank lines/spaces,
    modified the spyder/defaults directory, or added new icons/assets
  • Wrote at least one-line docstrings for any new functions
  • Added at least one unit test covering the changes, if at all possible
  • Described your changes and the motivation for them below
  • Noted what issue(s) this pull request resolves, creating one if needed
  • Included a screenshot, if this PR makes any visible changes to the UI

Description 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

A better thing would be to read the history from ipython, but I am not sure that this would work in every cases.
@pep8speaks
Copy link

pep8speaks commented May 15, 2018

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

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:]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace around +

@CAM-Gerlach CAM-Gerlach added this to the v3.3 milestone May 15, 2018
@CAM-Gerlach CAM-Gerlach changed the title Fixes #7080 PR: Fixes #7080 May 15, 2018
@CAM-Gerlach
Copy link
Member

CAM-Gerlach commented May 15, 2018

Thanks for doing this! I need to head to work now, but a few quick things:

  • Please briefly describe what your PR actually does in the title and the description, so we can follow it easily
  • Also, thanks for including the Fixes # message in your commit, but it's also good to include it in the body of the PR, which the template explicitly has a line for
  • Fix the PEP8 issue
  • The test failures are legitimate, and it looks like its due to a typo in your code (see comment). It's easy to make, but if you're using Spyder or had actually tested the change, it would have been easy to catch
  • Can you add a test for this?
  • Not sure why you deleted the PR template that specified several of these things in a checklist...(I added it back for your reference)

Copy link
Member

@CAM-Gerlach CAM-Gerlach left a 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!

@@ -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:
Copy link
Member

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.

@impact27 impact27 changed the title PR: Fixes #7080 PR: Limit the number on lines in the history according to the relevant setting. May 15, 2018
@CAM-Gerlach CAM-Gerlach dismissed their stale review May 15, 2018 22:50

All points addressed. Thanks!

@@ -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
Copy link
Member

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.

@@ -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')
Copy link
Member

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')

@ccordoba12
Copy link
Member

Things look good, I just left a minor comment.

@CAM-Gerlach CAM-Gerlach changed the title PR: Limit the number on lines in the history according to the relevant setting. PR: Limit the number of lines in the history according to the relevant setting. May 15, 2018
@CAM-Gerlach
Copy link
Member

@ccordoba12 Do we want a regression test for this to ensure the change is and remains effective?

@ccordoba12
Copy link
Member

A test would be nice, yes, but it doesn't seem easy to implement. Besides, the code looks good.

@CAM-Gerlach
Copy link
Member

Besides, the code looks good.

Well, those are some famous last words if I ever heard some, heh... :)

Copy link
Member

@ccordoba12 ccordoba12 left a 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.

@@ -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)]
Copy link
Member

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.

Copy link
Member

@CAM-Gerlach CAM-Gerlach May 26, 2018

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?

@ccordoba12 ccordoba12 changed the title PR: Limit the number of lines in the history according to the relevant setting. PR: Limit the number of lines in history according to the relevant setting Jun 15, 2018
@ccordoba12 ccordoba12 merged commit 40b430d into spyder-ide:3.x Jun 15, 2018
ccordoba12 added a commit that referenced this pull request Jun 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants