diff --git a/src/runestone.jl b/src/runestone.jl index d15b01b..5914417 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -1347,7 +1347,7 @@ function indent_function_or_macro(ctx::Context, node::Node) any_kid_changed = true end # Fifth node is the closing end keyword - end_idx = block_idx + 1 + end_idx = findnext(x -> kind(x) === K"end", kids, block_idx + 1)::Int end_node = kids[end_idx] @assert is_leaf(end_node) && kind(end_node) === K"end" if !has_tag(end_node, TAG_DEDENT) diff --git a/test/runtests.jl b/test/runtests.jl index 061cede..ac8453c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -454,6 +454,7 @@ end # macro-end @test format_string("macro f()\n$(sp)x\n$(sp)end") == "macro f()\n x\nend" + @test format_string("macro f() x end") == "macro f() x end" # let-end @test format_string("let a = 1\n$(sp)x\n$(sp)end") == "let a = 1\n x\nend" @test format_string("let\n$(sp)x\n$(sp)end") == "let\n x\nend"