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

Enforce leading and trailing newline in blocklike constructs #46

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

fredrikekre
Copy link
Owner

This patch introduces formatting for all blocklike constructs (if/try/function/begin/for/while/...) such that inner block always start and end with a newline character.

For example,

if x print("x") else print("y") end

will be reformatted as

if x
    print("x")
else
    print("y")
end

An exception is (currently) made for comments, for example

if x # comment
    print("x")
end

will not be formatted as

if x
    # comment
    print("x")
end

even though the comment is technically inside the block.

Closes #35.

This patch introduces formatting for all blocklike constructs
(`if`/`try`/`function`/`begin`/`for`/`while`/...) such that inner block
always start and end with a newline character.

For example,
```julia
if x print("x") else print("y") end
```
will be reformatted as
```julia
if x
    print("x")
else
    print("y")
end
```

An exception is (currently) made for comments, for example
```julia
if x # comment
    print("x")
end
```
will *not* be formatted as
```julia
if x
    # comment
    print("x")
end
```
even though the comment is technically inside the block.

Closes #35.
@fredrikekre fredrikekre merged commit e128bc9 into master Aug 21, 2024
14 checks passed
@fredrikekre fredrikekre deleted the fe/blocks branch August 21, 2024 14:20
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

Successfully merging this pull request may close these issues.

disallow end)
1 participant