Browse Source

Fix single line block unnesting with hidden whitespace, closes #79

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

6
src/runestone.jl

@ -2026,6 +2026,12 @@ function indent_block( @@ -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

2
test/runtests.jl

@ -1135,6 +1135,8 @@ end @@ -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")

Loading…
Cancel
Save