diff --git a/src/runestone.jl b/src/runestone.jl index 174e31a..683500f 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -849,7 +849,7 @@ function indent_if(ctx::Context, node::Node) end function indent_call(ctx::Context, node::Node) - @assert kind(node) === K"call" + @assert kind(node) in KSet"call dotcall" return indent_paren(ctx, node) end @@ -895,7 +895,7 @@ end # Mark opening and closing parentheses, in a call or a tuple, with indent and dedent tags. function indent_paren(ctx::Context, node::Node) - @assert kind(node) in KSet"call tuple parens" + @assert kind(node) in KSet"call dotcall tuple parens" kids = verified_kids(node) opening_paren_idx = findfirst(x -> kind(x) === K"(", kids)::Int closing_paren_idx = findnext(x -> kind(x) === K")", kids, opening_paren_idx + 1)::Int @@ -1147,7 +1147,7 @@ function insert_delete_mark_newlines(ctx::Context, node::Node) return indent_let(ctx, node) elseif is_begin_block(node) return indent_begin(ctx, node) - elseif kind(node) === K"call" && flags(node) == 0 + elseif kind(node) in KSet"call dotcall" && flags(node) == 0 # TODO: Why the flag check? return indent_call(ctx, node) elseif is_infix_op_call(node) return indent_op_call(ctx, node) diff --git a/test/runtests.jl b/test/runtests.jl index b7ae500..7ad2e3e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -392,18 +392,20 @@ end @test format_string("(a,\n$(sp)b\n$(sp))") == "(a,\n b\n)" @test format_string("(a,\n$(sp)b,\n$(sp))") == "(a,\n b,\n)" @test format_string("(\n$(sp)a,\n$(sp)b,\n$(sp))") == "(\n a,\n b,\n)" - # call - for sep in (",", ";") - @test format_string("f(a$(sep)\n$(sp)b)") == "f(a$(sep)\n b)" - @test format_string("f(a$(sep)\n$(sp)b\n$(sp))") == "f(a$(sep)\n b\n)" - @test format_string("f(a$(sep)\n$(sp)b,\n$(sp))") == "f(a$(sep)\n b,\n)" - @test format_string("f(\n$(sp)a$(sep)\n$(sp)b,\n$(sp))") == "f(\n a$(sep)\n b,\n)" + # call, dotcall + for sep in (",", ";"), d in ("", ".") + @test format_string("f$(d)(a$(sep)\n$(sp)b)") == "f$(d)(a$(sep)\n b)" + @test format_string("f$(d)(a$(sep)\n$(sp)b\n$(sp))") == "f$(d)(a$(sep)\n b\n)" + @test format_string("f$(d)(a$(sep)\n$(sp)b,\n$(sp))") == "f$(d)(a$(sep)\n b,\n)" + @test format_string("f$(d)(\n$(sp)a$(sep)\n$(sp)b,\n$(sp))") == "f$(d)(\n a$(sep)\n b,\n)" + end + # op-call, dot-op-call + for d in ("", ".") + @test format_string("a $(d)+\n$(sp)b") == "a $(d)+\n b" + @test format_string("a $(d)+ b $(d)*\n$(sp)c") == "a $(d)+ b $(d)*\n c" + @test format_string("a $(d)+\n$(sp)b $(d)*\n$(sp)c") == "a $(d)+\n b $(d)*\n c" + @test format_string("a $(d)||\n$(sp)b") == "a $(d)||\n b" end - # op-call - @test format_string("a +\n$(sp)b") == "a +\n b" - @test format_string("a + b *\n$(sp)c") == "a + b *\n c" - @test format_string("a +\n$(sp)b *\n$(sp)c") == "a +\n b *\n c" - @test format_string("a ||\n$(sp)b") == "a ||\n b" # assignment for op in ("=", "+=") @test format_string("a $(op)\n$(sp)b") == "a $(op)\n b"