Browse Source

Fix spaces around assignment with non-trivia operators.

pull/19/head
Fredrik Ekre 2 years ago
parent
commit
b2b3e905ed
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 2
      src/runestone.jl
  2. 3
      test/runtests.jl

2
src/runestone.jl

@ -282,7 +282,7 @@ function spaces_around_operators(ctx::Context, node::JuliaSyntax.GreenNode)
end end
function spaces_around_assignments(ctx::Context, node::JuliaSyntax.GreenNode) function spaces_around_assignments(ctx::Context, node::JuliaSyntax.GreenNode)
if !(is_assignment(node) && !JuliaSyntax.is_trivia(node)) if !(is_assignment(node) && !is_leaf(node) )
return nothing return nothing
end end
# for-loop nodes are of kind K"=" even when `in` or `∈` is used so we need to # for-loop nodes are of kind K"=" even when `in` or `∈` is used so we need to

3
test/runtests.jl

@ -173,6 +173,9 @@ end
op == "in" && sp == "" && continue op == "in" && sp == "" && continue
@test format_string("for i$(sp)$(op)$(sp)1:10\nend\n") == "for i $(op) 1:10\nend\n" @test format_string("for i$(sp)$(op)$(sp)1:10\nend\n") == "for i $(op) 1:10\nend\n"
end end
# Quoted assignment operators
@test format_string(":(=)") == ":(=)"
@test format_string(":(+=)") == ":(+=)"
end end
@testset "whitespace around <: and >:, no whitespace around ::" begin @testset "whitespace around <: and >:, no whitespace around ::" begin

Loading…
Cancel
Save