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

Wrong indentation for let / if-then-else expressions

Open davidfestal opened this issue 10 years ago • 2 comments

The new let and if then else expressions allow doing some nesting like this :

function buildParents(String entry) 
    => let(parents = entry.split('/'.equals).filter(not(String.empty)).exceptLast)
            if (exists firstParent = parents.first)
            then
                if (nonempty restOfParents = parents.rest.sequence())
                then restOfParents.scan(firstParent + "/")(
                    (path, nextParent) => "".join { path, nextParent + "/"})
                else { firstParent + "/"}
            else {};

However the Correct Indentation action (as well as the automatic indentation applied after copy/paste) formats it like that :

function buildParents(String entry) 
        => let(parents = entry.split('/'.equals).filter(not(String.empty)).exceptLast)
if (exists firstParent = parents.first)
then
if (nonempty restOfParents = parents.rest.sequence())
then restOfParents.scan(firstParent + "/")(
    (path, nextParent) => "".join { path, nextParent + "/"})
else { firstParent + "/"}
else {};

davidfestal avatar Feb 12 '15 14:02 davidfestal

@gavinking any thought about that and about the corresponding formatter issue ?

davidfestal avatar Feb 12 '15 14:02 davidfestal

@davidfestal This one is really pretty impossible unless we get the parser involved in the AutoEdit, which is something we don't currently depend on. I just committed a sorta partial solution, but I left it commented out, since it doesn't really work quite right.

gavinking avatar Mar 01 '15 19:03 gavinking