diff --git a/src/runestone.jl b/src/runestone.jl index dcb57ea..8dda47f 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -2026,6 +2026,12 @@ function indent_block( if kind(kids′[insert_idx]) === K"Whitespace" kids′, ws = popatview!(kids′, insert_idx) wsspn = span(ws) + elseif !is_leaf(kids′[insert_idx]) && + kind(first_leaf(kids′[insert_idx])) === K"Whitespace" + ws = first_leaf(kids′[insert_idx]) + kids′[insert_idx] = replace_first_leaf(kids′[insert_idx], nullnode) + any_kid_changed = true + wsspn = span(ws) end # If we end up in this code path we are most likely splitting a single line block # into multiples lines. This means that we haven't yet updated the indent level for diff --git a/test/runtests.jl b/test/runtests.jl index ce2c4c1..041b689 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1135,6 +1135,8 @@ end for mut in ("", "mutable ") @test format_string("$(mut)struct A$(d)x$(d)end") == "$(mut)struct A\n x\nend" end + # https://github.com/fredrikekre/Runic.jl/issues/79 + @test format_string("while true$(d)x += 1\nend") == "while true\n x += 1\nend" end # d-loop # module-end, baremodule-end for b in ("", "bare")