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

Option to add or at least not remove trailing semi-colons? #565

Open
chriselrod opened this issue Apr 7, 2022 · 5 comments
Open

Option to add or at least not remove trailing semi-colons? #565

chriselrod opened this issue Apr 7, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@chriselrod
Copy link
Contributor

When running code in the REPL, I prefer not to have it flooded with text. Especially every time a function returns a long vector.

Yet JuliaFormatter strips semicolons, meaning that is exactly what happens.

Note that code inside various blocks will often be run in the REPL whilst debugging.

@domluna
Copy link
Owner

domluna commented Apr 7, 2022

can you give an example ?

 julia> s = """
 a = 10;

 b = 20;
 """
 "a = 10;\n\nb = 20;\n"

 julia> format_text(s) |> print
 a = 10;

 b = 20;

the semicolons are preserved

@chriselrod
Copy link
Contributor Author

chriselrod commented Apr 7, 2022

julia> format_text("""
       begin
           a = rand(100);
           sum(a)
       end
       """) |> println
begin
    a = rand(100)
    sum(a)
end

When debugging, I often run the contents of blocks in my REPL line by line.

@domluna
Copy link
Owner

domluna commented Apr 7, 2022

ok ic

CSTParser doesn't support semicolons really at all but I think we could do something similar to what we do for inline comments to catch these

@domluna domluna added the bug Something isn't working label Apr 7, 2022
@chriselrod
Copy link
Contributor Author

Could we also get have an option we can set in our .JuliaFormatter.toml to end all lines with a semicolon?

@domluna domluna pinned this issue May 14, 2022
@stev47
Copy link

stev47 commented Sep 28, 2023

The removal of trailing semicolons can actually break code. Minimal example:

julia> code = raw":($([]...);)"
":(\$([]...);)"

julia> code |> Meta.parse |> eval
quote
end

julia> format_text(code) |> Meta.parse |> eval
ERROR: syntax: "..." expression outside call

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

3 participants