Open lucaswerkmeister opened 10 years ago
the IDE gives
extends
andsatisfies
a preIndent of 2
I much prefer that, though perhaps it should be configgable.
both currently give then and else a preIndent of 0, but I think it should be 1.
The issue is that I'm very limited in what I can do in the autoeditstrategy because i'm working at the character and token level. So I can't distinguish the else
operator from the else
block of an if
statement. I would much prefer if both were indented to the second level like other operators, but that's something I would need an AST for.
I much prefer that
alright, then I’ll make it configurable with a default value of 2.
The issue is that I'm very limited in what I can do in the autoeditstrategy because i'm working at the character and token level.
Maybe the formatter could add indentation information to the tokens during formatting, and the IDE would use that instead?
I don't see how that would work. The IDE throws away tokens every time you type something.
Oh… well at least I understand now why it slows down so much when editing FormattingVisitor.ceylon
:D (~1600 LOC, lexer + parser takes ~150ms)
Actually… I just noticed that what I said about the comprehensions isn’t true. Currently, both the IDE and the formatter output this:
value v = {
for (i1 in 1..100)
for (i2 in 1..100)
if (i1 < i2)
i1 -> i2
};
However, I really think it should be indented like this:
value v = {
for (i1 in 1..100)
for (i2 in 1..100)
if (i1 < i2)
i1 -> i2
};
@gavinking what do you think? Is the IDE’s indentation of this intentional?
@lucaswerkmeister I prefer your suggestion. IIRC, it would be very difficult to implement it in the AutoEditStrategy
. I can't consider either a closing paren or for
as triggering a "continuation", unfortunately.
Yeah, I currently have the same problem that I can't tie the indentation to any specific token, but I think it shouldn't be too difficult for me to adapt the formatter's architecture.
----- Ursprüngliche Nachricht ----- Von: "Gavin King" notifications@github.com Gesendet: 14.03.2014 12:49 An: "lucaswerkmeister/ceylon.formatter" ceylon.formatter@noreply.github.com Cc: "Lucas Werkmeister" mail@lucaswerkmeister.de Betreff: Re: [ceylon.formatter] Consistency with IDE intentation (#31)
@lucaswerkmeister I prefer your suggestion. IIRC, it would be very difficult to implement with in the AutoEditStrategy. I can't consider either a closing paren or for as triggering a "continuation", unfortunately. — Reply to this email directly or view it on GitHub.
Another example where the formatter is inconsistent with the IDE is #26. @gavinking any thoughts on that?
At the moment, the formatter is inconsistent in some points with the IDE’s indentation – for example, the IDE gives
extends
andsatisfies
a preIndent of 2, the formatter only 1 – and in other places, it’s consistent, but I dislike the behavior – for example, both currently givethen
andelse
a preIndent of 0, but I think it should be 1.@gavinking In general, how much of the IDE indentation strategy should I consider “intentional”? For example, I’m pretty sure that the missing indentation of chained comprehensions is just “forgot to implement that” or a bug and not intentional.
Code examples to illustrate my points above: