#144 open

[bug] double indentation

Reported by Swizec | January 4th, 2011 @ 01:25 AM

What I did: Accidentally selected text beyond the end of a line before going to a new line.

What I expected to happen: A new line to appear.

What actually happened: No new line was created, but the next line got another set of indentation.

Here's an example:

| represents the caret

  def __init__(self):<selection to the end of visible line>|
    super(ContactForm, self).__init__(*args, **kwargs)

After pressing enter this is what happenes

  def __init__(self):
  |   super(ContactForm, self).__init__(*args, **kwargs)

Not that even making that selection shouldn't be possible since it's beyond the scope of the text. The way I managed to get it was by going to the end of the line, holding shift and pressing the right arrow key.

Comments and changes to this ticket

  • rsms

    rsms January 4th, 2011 @ 01:32 AM

    • State changed from “new” to “open”
    • Assigned user set to “rsms”
    • Tag set to bug, indentation, text

    Confirmed to be reproducible in rsms/master@0c125ab68b63966c31bf5b3841a75151c045752e

  • mb

    mb January 20th, 2011 @ 01:14 AM

    Should it really insert a new line? This doesn't seem to be customary for OSX apps. TextEdit, TextMate, and Xcode, for example, do not behave this way -- TextMate and TextEdit just move the caret to the next line without inserting anything; Xcode inserts indentation only if the next line is scoped beneath the previous--otherwise it also does nothing (for example if you select the whitespace after a function declaration and an opening left-brace, it will add indentation to the next line, but if you select the whitespace after a #pragma that has an empty line after and hit return, it just moves to the next line without inserting anything). In all 3 apps, no extra newline is inserted (except at the very end of a document in the case of Xcode).

  • mb

    mb January 20th, 2011 @ 01:16 AM

    Correction to my previous comment: if the TextMate mode is set to Python then it also adds scoped indentation when you hit the return key.

  • Swizec

    Swizec January 20th, 2011 @ 02:22 AM

    Could someone confirm this bug even still exists? I have a vague memory of fixing it and sending a pull request.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

A text editor for Mac OS X

People watching this ticket