fredrikekre/Runic.jl

indentation of multiline tuples without parentheses

Opened this issue · 1 comments

Currently, a multiline tuple without parentheses receives indentation for all but the first element:

 1,
-2,
-3
+    2,
+    3

Should all elements rather be treated equally (as they are in the presence of parentheses)?

The current behavior looks particularly strange to me when a docstring is shared between two functions:

 "docstring for f and g"
 function f(x)
-    x
+        x
 end,
-function g(y)
-    y
+    function g(y)
+        y
 end

Note that the function body of f is indented two levels and that the final end is not aligned with the function it closes.

Currently, a multiline tuple without parentheses receives indentation for all but the first element:

This is a result of the "expression spanning multiple lines are indented" rule. I agree it looks a bit weird in isolation perhaps, but when do you really have a implicit tuple like that? The rule is supposed to format e.g.

letters = a, b, c, d,
e, f, g, h

into

letters = a, b, c, d,
    e, f, g, h

to make it more clear that the second line is a continuation of the first one.

The current behavior looks particularly strange to me when a docstring is shared between two functions:

I don't think I have ever seen code written like that with a top level tuple of functions. The typical way would be to write:

"docstring for f and g"
f, g

function f(x)
    x
end

function g(y)
    y
end

Anyway, looks like some bug anyway, I would have expected the result to be

"docstring for f and g"
function f(x)
    x
end,
    function g(y)
        y
    end