ceylon-ide-eclipse icon indicating copy to clipboard operation
ceylon-ide-eclipse copied to clipboard

Indentation of function arguments

Open FroMage opened this issue 9 years ago • 7 comments

When I have:

callToMethod(a,[ENTER] b, c)

And I press ENTER where indicated, I would like this indentation:

callToMethod(a,
             b, c)

That is, aligned with the method parameter list. Instead I get this:

callToMethod(a,
  b, c)

Aligned with nothing in particular, and very confusing.

FroMage avatar Sep 16 '15 12:09 FroMage

I don’t see how that’s aligned with anything.

lucaswerkmeister avatar Sep 16 '15 12:09 lucaswerkmeister

Sorry, I aligned it manually using the GitHub editor which is not a fixed-width font. Hold on.

FroMage avatar Sep 16 '15 12:09 FroMage

Fixed.

FroMage avatar Sep 16 '15 12:09 FroMage

Well that's what you want, but I don't particularly like lining up things, especially when that results in enormous indents. ;)

Although perhaps this could be made smart enough to follow the following rules:

  1. if you press enter after an argument, we line up the cursor with the first argument
  2. if you press enter after the opening bracket, we just do a double indent

quintesse avatar Sep 16 '15 12:09 quintesse

I think the formatter has settings for this kind of thing. I doubt it would be a good idea to try to make AutoEdit do this automatically.

@quintesse forget about trying to add any "smart" rules to AutoEdit. It is fundamentally stupid and has to be that way because anything "smart" would have to assume syntactically legal code which is of course a totally unreasonable assumption here. AutoEdit can't distinguish an argument list from any other kind of list of things in parens.

gavinking avatar Sep 16 '15 14:09 gavinking

The formatter doesn’t do alignment, just indentation. So the formatter will produce:

callToMethod(a,
    b, c)

The indentation depth (4 spaces, 2 spaces, 7 tabs) is adjustable, but the number of levels introduced by the parameter list isn’t.

lucaswerkmeister avatar Sep 16 '15 14:09 lucaswerkmeister

I'm fine if it's an option, but yeah, I really want alignment, ATM I have to always do this manually and it sucks. The alternative of just indenting a random level is pretty much always wrong, even when the name of the method you're calling is smaller than the indent level, which would place the remaining arguments after the alignment of your method. I don't see how this can be desired.

FroMage avatar Sep 17 '15 14:09 FroMage