From f0a6d32476566ca130e113e549b856424a12d9a0 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Sat, 3 Aug 2024 13:44:54 +0200 Subject: [PATCH] Fix handling of comments within import/using lists --- src/runestone.jl | 2 +- test/runtests.jl | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/runestone.jl b/src/runestone.jl index 390f675..8cb0e09 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -1039,7 +1039,7 @@ function format_importpath(ctx::Context, node::Node) node′ = replace_first_leaf(node, spacebar) else # No whitespace, insert - @assert kind(first_leaf(node)) in KSet"Identifier @" || + @assert kind(first_leaf(node)) in KSet"Identifier @ Comment" || JuliaSyntax.is_operator(first_leaf(node)) kids′ = copy(verified_kids(node)) pushfirst!(kids′, spacebar) diff --git a/test/runtests.jl b/test/runtests.jl index e45685f..9c6a615 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -848,6 +848,8 @@ end "$(verb) A: $(a), $(b)" @test format_string("$(verb) $(sp)A: $(sp)$(a)$(sp),\n$(b)") == "$(verb) A: $(a),\n $(b)" + @test format_string("$(verb) $(sp)A: $(sp)$(a)$(sp),$(sp)# c\n$(b)") == + "$(verb) A: $(a), # c\n $(b)" end end end