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 bug with YASStyle (?) #387

Closed
ericphanson opened this issue Mar 26, 2021 · 4 comments
Closed

indentation bug with YASStyle (?) #387

ericphanson opened this issue Mar 26, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@ericphanson
Copy link

JuliaDSP/DSP.jl@dee38ad#diff-7eb8d556545d1576a135ef609daf44651b1cf2cd46735cb90991b0ffac1b91deR39-R50

this looks strange; I formatted with JuliaFormatter v0.13.5 (Tokenize.jl v0.5.13 to avoid #386) via format("src/multitaper_spectrogram.jl", style=YASStyle()). I don't think it should suddenly put all these arguments way indented!

@ericphanson ericphanson changed the title indentation bug with YASStyle indentation bug with YASStyle (?) Mar 26, 2021
@domluna domluna added the bug Something isn't working label Mar 26, 2021
@domluna
Copy link
Owner

domluna commented Apr 2, 2021

this is due to kind of odd parsing where (...) is not treated as a tuple but rather a collection of individual nodes/tokens so it throws the indentation off

EDIT: actually complete mind lapse this is how call is normally parsed lol, it's just that for YAS style specifically since it relies on the first ( for indentation positioning if the curly part is nested then the indentation is thrown off. The solution is to delay setting the indentation until the first arg after ( is reached

domluna added a commit that referenced this issue Apr 2, 2021
Handles the edge case where the first argument of a Call node
is nestable. For example:

```
new{T1,T2}(arg1,arg2)
```

In this case if the indent is set to the offset of the first argument after
`(` and `new{T1,T2}` is nested, the indentation will be incorrect.

before (aligned to after the initial position of `(`):

```
new{T1,
    T2}(arg1,
           arg2)
```

after (aligned to after new position of `(`):

```
new{T1,
    T2}(arg1,
        arg2)
```
@domluna
Copy link
Owner

domluna commented Apr 2, 2021

@ericphanson can you verify #394?

@ericphanson
Copy link
Author

Yes, looks much much better!

JuliaDSP/DSP.jl@e476fef#diff-42b63c32cfe9564f97f2b1c492af2a473460ca00579a8c2ae854db0741ad7f82R42-R47

Bug looks fixed to me!

It seems like there's an unusual tradeoff to make between how many type parameters to put on a line vs how many arguments, since more type parameters mean less room per line for the arugments. I think in this case it might be worth making one more line for the type parameters so that the arguments aren't so squished up together, but I understand it might be hard to find the best balance in general.

@domluna
Copy link
Owner

domluna commented Apr 2, 2021

#359 may help with that but it's all subjective so it's tricky to figure out what's "best"

@domluna domluna closed this as completed in eba069a Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants