From 6e59ab319628409875809c9465ef76a5a1a3a8e4 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Sun, 7 Jul 2024 13:44:19 +0200 Subject: [PATCH] Remove trailing `;` in paren-blocks --- src/runestone.jl | 2 +- test/runtests.jl | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/runestone.jl b/src/runestone.jl index 58b004d..47910ae 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -607,7 +607,7 @@ function spaces_in_listlike(ctx::Context, node::Node) end else @assert state === :expect_closing - if kind(kid′) === K"," || + if kind(kid′) === K"," || kind(kid′) === K";" || (kind(kid′) === K"Whitespace" && peek(i) !== K"Comment") # Trailing comma (when not wanted) and space not followed by a comment are # removed diff --git a/test/runtests.jl b/test/runtests.jl index d024526..db56f7b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -201,7 +201,7 @@ end end end -@testset "spaces in lists" begin +@testset "spaces in listlike" begin for sp in ("", " ", " "), a in ("a", "a + a", "a(x)"), b in ("b", "b + b", "b(y)") # tuple, call, dotcall, vect, ref for (o, c) in (("(", ")"), ("f(", ")"), ("f.(", ")"), ("[", "]"), ("T[", "]")) @@ -271,6 +271,10 @@ end @test format_string("$(x){\n$(sp)$(a)$(sp);$(sp)$(b)$(sp)\n}") == "$(x){\n $(a); $(b)$(tr)\n}" end + # Trailing `;` in paren-block + @test format_string("(a = A;)") == "(a = A)" + @test format_string("cond && (a = A;)") == "cond && (a = A)" + @test format_string("(a = A; b = B;)") == "(a = A; b = B)" end @testset "whitespace around ->" begin