From 0660870c082c7e5c142cd49a3bd5052343953d62 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 24 Jul 2024 01:36:46 +0200 Subject: [PATCH] Fix bug in formatting in export/public expressions with macronames --- src/runestone.jl | 7 +++++-- test/runtests.jl | 12 ++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/runestone.jl b/src/runestone.jl index e924f6e..36d1381 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -973,13 +973,16 @@ function spaces_in_export_public(ctx::Context, node::Node) end state = :expect_identifier elseif state === :expect_identifier - if kind(kid) === K"Identifier" + state = :expect_comma + if kind(kid) in KSet"Identifier @ MacroName" any_changes && push!(kids′, kid) accept_node!(ctx, kid) + if kind(kid) === K"@" + state = :expect_identifier + end else @assert false end - state = :expect_comma else @assert state === :expect_comma state = :expect_space diff --git a/test/runtests.jl b/test/runtests.jl index b3d678a..a0a0a9f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -799,12 +799,12 @@ end end @testset "spaces in export/public" begin - for sp in ("", " ", " ", "\t"), verb in ("export", "public") - @test format_string("$(verb) $(sp)a") == "$(verb) a" - @test format_string("$(verb)\na") == "$(verb)\n a" - @test format_string("$(verb) $(sp)a$(sp),$(sp)b") == "$(verb) a, b" - @test format_string("$(verb) a$(sp),\nb") == "$(verb) a,\n b" - @test format_string("$(verb) \na$(sp),\nb") == "$(verb)\n a,\n b" + for sp in ("", " ", " ", "\t"), verb in ("export", "public"), (a, b) in (("a", "@b"), ("@a", "b")) + @test format_string("$(verb) $(sp)$(a)") == "$(verb) $(a)" + @test format_string("$(verb)\n$(a)") == "$(verb)\n $(a)" + @test format_string("$(verb) $(sp)$(a)$(sp),$(sp)$(b)") == "$(verb) $(a), $(b)" + @test format_string("$(verb) $(a)$(sp),\n$(b)") == "$(verb) $(a),\n $(b)" + @test format_string("$(verb) \n$(a)$(sp),\n$(b)") == "$(verb)\n $(a),\n $(b)" end end