Browse Source

Fix nested module indent with var"..." as module name

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

2
src/runestone.jl

@ -2137,7 +2137,7 @@ function indent_module(ctx::Context, node::Node)
# Third node is the module identifier # Third node is the module identifier
id_idx = 3 id_idx = 3
id_node = kids[id_idx] id_node = kids[id_idx]
@assert kind(id_node) === K"Identifier" @assert kind(id_node) in KSet"Identifier var"
# Fourth node is the module body block. # Fourth node is the module body block.
block_idx = 4 block_idx = 4
block_node′ = indent_block(ctx, kids[block_idx]) block_node′ = indent_block(ctx, kids[block_idx])

3
test/runtests.jl

@ -571,6 +571,9 @@ end
# nested documented modules # nested documented modules
@test format_string("\"doc\"\n$(b)module A\n\"doc\"\n$(b)module B\n$(sp)x\n$(sp)end\n$(sp)end") == @test format_string("\"doc\"\n$(b)module A\n\"doc\"\n$(b)module B\n$(sp)x\n$(sp)end\n$(sp)end") ==
"\"doc\"\n$(b)module A\n\"doc\"\n$(b)module B\n x\nend\nend" "\"doc\"\n$(b)module A\n\"doc\"\n$(b)module B\n x\nend\nend"
# var"" as module name
@test format_string("$(b)module var\"A\"\n$(sp)x\n$(sp)end\nf") ==
"$(b)module var\"A\"\n x\nend\nf"
end end
# tuple # tuple
@test format_string("(a,\n$(sp)b)") == "(\n a,\n b,\n)" @test format_string("(a,\n$(sp)b)") == "(\n a,\n b,\n)"

Loading…
Cancel
Save