From f517d032f311914abcfa557446f5e633edb0e707 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Mon, 8 Jul 2024 14:07:06 +0200 Subject: [PATCH] Fix single line do-end terminated by semicolon --- src/runestone.jl | 4 ++-- test/runtests.jl | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/runestone.jl b/src/runestone.jl index 47cd2ae..9fa7d7d 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -937,7 +937,7 @@ function spaces_around_keywords(ctx::Context, node::Node) if kind(node) === K"do" nkid = kids[i + 1] @assert kind(nkid) === K"tuple" - if !any(!JuliaSyntax.is_whitespace, verified_kids(nkid)) + if !any(x -> !(JuliaSyntax.is_whitespace(x) || kind(x) === K";"), verified_kids(nkid)) state = :closing end end @@ -990,7 +990,7 @@ function spaces_around_keywords(ctx::Context, node::Node) @assert false # Unreachable? else # Reachable in e.g. `T where{T}`, `if(`, ... insert space - @assert kind(node) in KSet"where if elseif while" + @assert kind(node) in KSet"where if elseif while do" any_changes = true if kids′ === kids kids′ = kids[1:(i - 1)] diff --git a/test/runtests.jl b/test/runtests.jl index 5739ade..056d38a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -402,6 +402,7 @@ end @test format_string("A$(sp)where$(sp){T}$(sp)where$(sp){S}") == "A where {T} where {S}" @test format_string("f()$(sp)do$(sp)x\ny\nend") == "f() do x\n y\nend" @test format_string("f()$(sp)do\ny\nend") == "f() do\n y\nend" + @test format_string("f()$(sp)do; y end") == "f() do; y end" # After `where` (anywhere else?) a newline can be used instead of a space @test format_string("A$(sp)where$(sp)\n{A}") == "A where\n{A}" end