Skip to content

Commit

Permalink
Fix space-around-operator with non-space whitespace (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored Oct 22, 2024
1 parent 0bb9b42 commit 797a1ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/runestone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ function spaces_around_x(ctx::Context, node::Node, is_x::F, n_leaves_per_x::Int
# Replace the whitespace node of the kid
kid′ = replace_first_leaf(kid, ws)
@assert span(kid′) == span(kid) - span(kid_ws) + 1
bytes_to_skip = span(kid) - span(kid′)
@assert bytes_to_skip > 0
replace_bytes!(ctx, "", bytes_to_skip)
replace_bytes!(ctx, " ", span(kid_ws))
accept_node!(ctx, kid′)
any_changes = true
if kids′ === kids
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@ end
@test format_string("(\na, x -> @m(x[i])\n)") == "(\n a, x -> @m(x[i]),\n)"
# Weird cornercase where a trailing comma messes some cases up (don't recall...)
@test format_string("{\n@f\n}") == "{\n @f\n}"
# Non space whitespace (TODO: Not sure if a JuliaSyntax bug or not?)
@test format_string(String(UInt8[0x61, 0x20, 0x3d, 0x3d, 0x20, 0xc2, 0xa0, 0x62, 0x3a, 0x63])) ==
"a == b:c"
end

@testset "whitespace around ->" begin
Expand Down

0 comments on commit 797a1ba

Please sign in to comment.