diff --git a/src/runestone.jl b/src/runestone.jl index 3de41f8..2e30be4 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -3279,7 +3279,7 @@ function remove_trailing_semicolon(ctx::Context, node::Node) r = remove_trailing_semicolon_block(ctx, node) return r end - if !(!is_leaf(node) && kind(node) in KSet"if elseif quote function for let while macro try catch finally else") + if !(!is_leaf(node) && kind(node) in KSet"if elseif quote function for let while macro try catch finally else do struct") return nothing end if kind(node) === K"quote" && JuliaSyntax.has_flags(node, JuliaSyntax.COLON_QUOTE) diff --git a/test/runtests.jl b/test/runtests.jl index 2eae040..05f43b3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1164,7 +1164,7 @@ end """ for prefix in ( "begin", "quote", "for i in I", "let", "let x = 1", "while cond", - "if cond", "macro f()", "function f()", + "if cond", "macro f()", "function f()", "f() do", "f() do x", ) @test format_string("$(prefix)\n$(body)\nend") == "$prefix\n$(bodyfmt)\nend" end @@ -1184,6 +1184,10 @@ end format_string("try\n$(bodyfmt)\ncatch err\n$(bodyfmt)\nfinally\n$(bodyfmt)\nend") @test format_string("try\n$(body)\ncatch err\n$(body)\nelse\n$(body)\nend") == format_string("try\n$(bodyfmt)\ncatch err\n$(bodyfmt)\nelse\n$(bodyfmt)\nend") + for mut in ("", "mutable ") + @test format_string("$(mut)struct A\na::Int;\nend") == + "$(mut)struct A\n a::Int\nend" + end # Top-level semicolons are kept (useful if you want to supress output in various # contexts) let str = """