Browse Source

Fix empty functions with Unicode symbol names

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

4
src/runestone.jl

@ -1348,7 +1348,9 @@ function indent_function_or_macro(ctx::Context, node::Node)
@assert is_longform_anon_function(node) @assert is_longform_anon_function(node)
end end
sig_node = kids[sig_idx] sig_node = kids[sig_idx]
if kind(sig_node) === K"Identifier" # Identifier for regular names but "not function call" for empty functions with Unicode
# symbols??
if kind(sig_node) === K"Identifier" || !(kind(sig_node) in KSet"call where :: tuple")
# Empty function definition like `function f end`. # Empty function definition like `function f end`.
# TODO: Make sure the spaces around are correct # TODO: Make sure the spaces around are correct
end_idx = findnext(x -> kind(x) === K"end", kids, sig_idx + 1)::Int end_idx = findnext(x -> kind(x) === K"end", kids, sig_idx + 1)::Int

1
test/runtests.jl

@ -464,6 +464,7 @@ end
@test format_string("function f()\n$(sp)x\n$(sp)end") == @test format_string("function f()\n$(sp)x\n$(sp)end") ==
"function f()\n x\nend" "function f()\n x\nend"
@test format_string("function f end") == "function f end" @test format_string("function f end") == "function f end"
@test format_string("function ∉ end") == "function ∉ end"
# macro-end # macro-end
@test format_string("macro f()\n$(sp)x\n$(sp)end") == @test format_string("macro f()\n$(sp)x\n$(sp)end") ==
"macro f()\n x\nend" "macro f()\n x\nend"

Loading…
Cancel
Save