Browse Source

Fix ternary (and others) with comments in between things

pull/19/head
Fredrik Ekre 1 year ago
parent
commit
124cd48228
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 4
      src/runestone.jl
  2. 4
      test/runtests.jl

4
src/runestone.jl

@ -255,7 +255,9 @@ function spaces_around_x(ctx::Context, node::Node, is_x::F, n_leaves_per_x::Int @@ -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

4
test/runtests.jl

@ -317,6 +317,10 @@ end @@ -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

Loading…
Cancel
Save