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

Eliminate extra validation after two newlines. #157

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ env:
- TOXENV=py33
- TOXENV=py34
- TOXENV=pypy
- TOXENV=pypy3
install:
- travis_retry pip install tox
script:
Expand Down
15 changes: 7 additions & 8 deletions ptpython/key_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,13 @@ def at_the_end(b):

elif at_the_end(b) and b.document.text.replace(' ', '').endswith(
'\n' * (empty_lines_required - 1)):
if b.validate():
# When the cursor is at the end, and we have an empty line:
# drop the empty lines, but return the value.
b.document = Document(
text=b.text.rstrip(),
cursor_position=len(b.text.rstrip()))

b.accept_action.validate_and_handle(event.cli, b)
# When the cursor is at the end, and we have an empty line:
# drop the empty lines, but return the value.
b.document = Document(
text=b.text.rstrip(),
cursor_position=len(b.text.rstrip()))

b.accept_action.validate_and_handle(event.cli, b)
else:
auto_newline(b)

Expand Down