From b2b3e905ed0df4a3537141f56acac3835873f3d9 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 29 May 2024 09:33:42 +0200 Subject: [PATCH] Fix spaces around assignment with non-trivia operators. --- src/runestone.jl | 2 +- test/runtests.jl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/runestone.jl b/src/runestone.jl index 33d4674..caafcd3 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -282,7 +282,7 @@ function spaces_around_operators(ctx::Context, node::JuliaSyntax.GreenNode) end 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 end # for-loop nodes are of kind K"=" even when `in` or `∈` is used so we need to diff --git a/test/runtests.jl b/test/runtests.jl index 913c14a..fe4ae7d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -173,6 +173,9 @@ end op == "in" && sp == "" && continue @test format_string("for i$(sp)$(op)$(sp)1:10\nend\n") == "for i $(op) 1:10\nend\n" end + # Quoted assignment operators + @test format_string(":(=)") == ":(=)" + @test format_string(":(+=)") == ":(+=)" end @testset "whitespace around <: and >:, no whitespace around ::" begin