Skip to content

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

Merged
takluyver merged 1 commit into
ipython:masterfrom
Carreau:fix-newline-indentation
Feb 9, 2017
Merged

Indent on new line by looking at the text before the cursor.#10264
takluyver merged 1 commit into
ipython:masterfrom
Carreau:fix-newline-indentation

Conversation

@Carreau
Copy link
Copy Markdown
Member

@Carreau 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 ipython#9283
d.cursor_position_row >= d.line_count - d.empty_line_count_at_the_end()
):
b.insert_text('\n' + (' ' * (indent or 0)))
return
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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
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
Copy Markdown
Member Author

Carreau commented Feb 9, 2017

@meeseeksdev backport to 5.x

lumberbot-app 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
@Carreau Carreau deleted the fix-newline-indentation branch February 9, 2017 20:03
@Carreau Carreau added the backported PR that have been backported by MrMeeseeks label Feb 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported PR that have been backported by MrMeeseeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants