Browse Source

Fix stripping of trailing `;` in listlike

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

6
src/runestone.jl

@ -612,7 +612,13 @@ function spaces_in_listlike(ctx::Context, node::Node) @@ -612,7 +612,13 @@ function spaces_in_listlike(ctx::Context, node::Node)
end
else
# Nothing in the parameter node needed, overwrite it fully
any_kid_changed = true
replace_bytes!(ctx, "", span(kid′))
if any_kid_changed
if kids′ === kids
kids′ = kids[1:(i - 1)]
end
end
end
else
# TODO: Tag for requiring trailing comma.

5
test/runtests.jl

@ -264,9 +264,10 @@ end @@ -264,9 +264,10 @@ end
@test format_string("# a\n$(a)$(sp),\n# b\n$(b)") ==
"# a\n$(a),\n # b\n $(b)"
end
# Single item
# Single item with trailing `,` and `;`
@test format_string("($(sp)$(a)$(sp),$(sp))") == "($(a),)"
@test format_string("f($(sp)$(a)$(sp),$(sp))") == "f($(a))"
@test format_string("f($(sp)$(a)$(sp),$(sp))") ==
format_string("f($(sp)$(a)$(sp);$(sp))") == "f($(a))"
# Keyword arguments
@test format_string("f($(sp)$(a)$(sp);$(sp)$(b)$(sp))") ==
format_string("f($(sp)$(a)$(sp);$(sp)$(b)$(sp),$(sp))") ==

Loading…
Cancel
Save