#221 ✓ resolved
nitsujri

Increasing/Decreasing indent reformats tabbing

Reported by nitsujri | May 16th, 2010 @ 06:58 PM

Currently

Regardless of current tabbing, the auto-formatter changes the tabbing to what it thinks it should be even if the user wanted something else.

Expected

Increasing/Decreasing indent does not change formatting of text.

Reproduce

  1. Write text:
    def my_method
    func_call({
     :arg1 => 1,
     :arg2 => 2
    })
    end
    
  2. Highlight and decrease indent using ctrl + [
  3. Text changes to:
    def my_method
    func_call({
     :arg1 => 1,
     :arg2 => 2
     })            <- Changed line
    end
    

(This example 'kinda' shows what I'm talking about, lighthouse doesn't maintain the exact indenting, sadly.)

Edit: Modified to be more exact based upon findings from conversation below.

Comments and changes to this ticket

  • agmcleod

    agmcleod May 16th, 2010 @ 07:33 PM

    Just tried this out on my mac. I wrote it like:

    def method_name
    my_var = {
      :arg => 1,
      :arg2 => 2
    }
    end
    
    I selected the start of my_var, so the caret right before the m. I used the mouse to select it all to just after the closing bracies. I used cmd+] and it indented as i would expect:
    def method_name
      my_var = {
        :arg => 1,
        :arg2 => 2
      }
    end
    

    This worked when i had positioned the :args using spaces or a 2 space tab. It didn't seem to matter.

  • agmcleod

    agmcleod May 17th, 2010 @ 02:09 PM

    Just gave this a try on my windows work machine as well, and I had no issues. Could you try using the code block declarative as said in: http://help.lighthouseapp.com/faqs/getting-started/how-do-i-format-... to show us how this is specifically going wrong? Just want to make sure I tested it correctly.

  • nitsujri

    nitsujri May 18th, 2010 @ 02:19 AM

    Sorry, checked it more thoroughly and apparently it only happens with () only when you're using ctrl + [ and not ctrl + ]

    def method_name
      some_func({
        :arg1 => 1,
        :arg2 => 2
      })
    end
    

    with ctrl + [ ends up as:

    def method_name
      some_func({
        :arg1 => 1,
        :arg2 => 2
        })
    end
    

    How did you get the color highlighting? I was using the @@@ both times, but apparently naming it rubyonrails is not the way to go.

    Thanks for looking into this agmcleod!

    Justin

    About my setup:

    Ubuntu: 10.04 Lucid Lynx
    About: Redcar
    Version: 0.3.5
    Ruby Version: 1.8.7
    Jruby version: 1.4.0
    Redcar.environment: user
    http://redcareditor.com

  • nitsujri

    nitsujri May 18th, 2010 @ 02:20 AM

    Oh, i got color... neato. n/m that last question.

  • agmcleod

    agmcleod May 18th, 2010 @ 04:45 PM

    I see. I run into that now as well. For instance i just typed:

    def method_name
      some_func({})
    end
    

    With my caret between the braces, and i hit enter, it results in your second example. If i enter in the values and have it lined up correctly, select the text there and hit ctrl+[, it moves like you said, and continues to move in that format. I just tested quickly in a javascript file, and this is not a problem. One uses say (function() {}); quite frequently, especially with jquery.

    I'll have a look into it after work, see what i can find out.

  • Daniel Lucraft

    Daniel Lucraft May 26th, 2010 @ 06:13 AM

    • State changed from “new” to “open”

    OK, lets see if I've got this right. You have the cursor at <c> and you press enter:

    some_func({<c>})
    

    What results is

    some_func({
      <c>})
    

    but what we should get is:

    some_func({
      <c>
    })
    

    Which is Textmate's behaviour.

  • nitsujri

    nitsujri May 26th, 2010 @ 06:26 AM

    Right then

    some_func({
      <c>
    })
    

    highlight the block and, press ctrl+[, or even press any combo of ctrl+[ and ctrl+] and the indentation will automatically change at some point when the expected behavior is for it to not change inside the block, but simply increase/decrease indent as a whole block.

    Side note, I've actually found a number of bugs with the auto indenter randomly changes indentation since the start of this bug. It happens a lot with HAML because there's no closing tag so it can't tell where things 'should' go. Dan, would you like me to open new ones or add to this one or just leave it for now?

  • Daniel Lucraft

    Daniel Lucraft May 26th, 2010 @ 10:33 AM

    hi nitsujri, Could you comment with the other indentation problems on here:
    http://redcar.lighthouseapp.com/projects/25090-redcar/tickets/226-a...

    I know there are a bunch of issues.

    thanks.

  • Mat Schaffer

    Mat Schaffer May 17th, 2011 @ 08:19 PM

    Ah, I see if you start with

    some_function({
      
    })
    

    Then highlight the code and intent with Ctrl+] then outdent with Ctrl+[ again you get this:

    some_function({
      
      })
    

    Checked on 2aa40fc7, OS X.

  • Daniel Lucraft

    Daniel Lucraft May 19th, 2011 @ 09:09 PM

    • State changed from “open” to “resolved”

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 programmer's text editor for Gnome.

People watching this ticket

Pages