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

Indent on new line by looking at the text before the cursor. #10264

Merged
merged 1 commit into from Feb 9, 2017

Conversation

@Carreau
Copy link
Member

Carreau commented Feb 9, 2017

that would allow edit like the following to insert the right amount of
space on the newline (| is the cursor)

class Bar:
    def __init__(self):|<enter>
        self.filed=0

Instead of inserting a blank line with 0 space.

Closes #9283


@takluyver can you have a look ?

that would allow edit like the following to insert the right amount of
space on the newline (`|` is the cursor)

    class Bar:
        def __init__(self):|<enter>
            self.filed=0

Instead of inserting a blank line with 0 space.

Closes #9283
d.cursor_position_row >= d.line_count - d.empty_line_count_at_the_end()
):
b.insert_text('\n' + (' ' * (indent or 0)))
return

This comment has been minimized.

Copy link
@Carreau

Carreau Feb 9, 2017

Author Member

ALso I'm unsure, but it seem to me that this block is completely redundant and can be remove. It is taken care of by the block below. (this is due to the fact that we cut the text at the cursor position, so status will never be 'ready'

This comment has been minimized.

Copy link
@Carreau

Carreau Feb 9, 2017

Author Member

Scratch that.

In [1]: def foo():
   ...:     pass
   ...: |<enter>
   ...: def bar():
   ...:     pass

Above example insert a new line with this patch.
Execute if I remove above block.

Carreau added a commit to Carreau/ipython that referenced this pull request Feb 9, 2017
Closes ipython#9588

Similar to ipython#10264, but with a simpler logic as we never execute.
Carreau added a commit to Carreau/ipython that referenced this pull request Feb 9, 2017
Closes ipython#9588

Similar to ipython#10264, but with a simpler logic as we never execute.
@takluyver takluyver modified the milestones: 6.0, 5.3 Feb 9, 2017
@takluyver takluyver merged commit 2405af1 into ipython:master Feb 9, 2017
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Carreau added a commit to Carreau/ipython that referenced this pull request Feb 9, 2017
Closes ipython#9588

Similar to ipython#10264, but with a simpler logic as we never execute.
@Carreau
Copy link
Member Author

Carreau commented Feb 9, 2017

@meeseeksdev backport to 5.x

meeseeksdev bot pushed a commit that referenced this pull request Feb 9, 2017
…the cursor.

that would allow edit like the following to insert the right amount of
space on the newline (`|` is the cursor)

    class Bar:
        def __init__(self):|<enter>
            self.filed=0

Instead of inserting a blank line with 0 space.

Closes  9283

---

 takluyver can you have a look ?
Carreau added a commit that referenced this pull request Feb 9, 2017
Backport PR #10264 on branch 5.x
@Carreau Carreau deleted the Carreau:fix-newline-indentation branch Feb 9, 2017
@Carreau Carreau added the backported label Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.