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

Merged
merged 1 commit into from Feb 9, 2017

Conversation

Projects
None yet
2 participants
@Carreau
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 ?

Indent on new line by looking at the text before 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
+ 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.

@Carreau

Carreau Feb 9, 2017

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'

@Carreau

Carreau Feb 9, 2017

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.

@Carreau

Carreau Feb 9, 2017

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

Carreau Feb 9, 2017

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

Improve indentation of next line when using CTRL-o in terminal.
Closes #9588

Similar to #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

Improve indentation of next line when using CTRL-o in terminal.
Closes #9588

Similar to #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

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

Improve indentation of next line when using CTRL-o in terminal.
Closes #9588

Similar to #10264, but with a simpler logic as we never execute.
@Carreau

This comment has been minimized.

Show comment
Hide comment
@Carreau

Carreau Feb 9, 2017

Member

@meeseeksdev backport to 5.x

Member

Carreau commented Feb 9, 2017

@meeseeksdev backport to 5.x

meeseeksdev bot pushed a commit that referenced this pull request Feb 9, 2017

Backport PR #10264: Indent on new line by looking at the text before …
…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

@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