Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indentation of multiline tuples without parentheses #37

Open
matthias314 opened this issue Aug 7, 2024 · 1 comment
Open

indentation of multiline tuples without parentheses #37

matthias314 opened this issue Aug 7, 2024 · 1 comment

Comments

@matthias314
Copy link

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.

@fredrikekre
Copy link
Owner

fredrikekre commented Aug 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants