diff --git a/src/runestone.jl b/src/runestone.jl index dd0b460..b65b429 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -255,7 +255,9 @@ function spaces_around_x(ctx::Context, node::Node, is_x::F, n_leaves_per_x::Int any_changes && push!(kids′, kid) accept_node!(ctx, kid) looking_for_whitespace = kind(last_leaf(kid)) !== K"Whitespace" - if looking_for_x + if kind(kid) === K"Comment" + # Just skip through and keep the state? + elseif looking_for_x # We are looking for x, check we have them all otherwise keep looking @assert is_x(kid)::Bool n_x_leaves_visited += 1 diff --git a/test/runtests.jl b/test/runtests.jl index e1f03f2..c338130 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -317,6 +317,10 @@ end "a ? b : c ? d : e" @test format_string("a$(sp)?\nb$(sp):\nc$(sp)?\nd$(sp):\ne") == "a ?\n b :\n c ?\n d :\n e" + # Comment in x-position + @test format_string("a$(sp)?$(sp)b$(sp)#==#$(sp):\nc") == "a ? b #==# :\n c" + # Comment in other-position + @test format_string("a$(sp)?$(sp)#==#$(sp)b$(sp):\nc") == "a ? #==# b :\n c" end end