Skip to content

Commit

Permalink
Use a mutable type instead of ref fields
Browse files Browse the repository at this point in the history
  • Loading branch information
tecosaur committed Aug 11, 2024
1 parent 04b2323 commit da6f7aa
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/JuliaSyntaxHighlighting.jl
Original file line number Diff line number Diff line change
@@ -132,10 +132,10 @@ function paren_type(k::Kind)
end
end

struct ParenDepthCounter
paren::Base.RefValue{UInt}
bracket::Base.RefValue{UInt}
curly::Base.RefValue{UInt}
mutable struct ParenDepthCounter
paren::UInt
bracket::UInt
curly::UInt
end

ParenDepthCounter() =
@@ -305,17 +305,17 @@ function _hl_annotations!(highlights::Vector{Tuple{UnitRange{Int}, Pair{Symbol,
end
elseif JuliaSyntax.is_error(nkind); :julia_error
elseif ((depthchange, ptype) = paren_type(nkind)) |> last != :none
depthref = getfield(pdepths, ptype)[]
depthref = getfield(pdepths, ptype)
pdepth = if depthchange > 0
getfield(pdepths, ptype)[] += depthchange
setfield!(pdepths, ptype, depthref + depthchange)
else
depth0 = getfield(pdepths, ptype)[]
getfield(pdepths, ptype)[] += depthchange
depth0 = getfield(pdepths, ptype)
setfield!(pdepths, ptype, depthref + depthchange)
depth0
end
if pdepth <= 0 && UNMATCHED_DELIMITERS_ENABLED[]
if pdepth <= 0 && UNMATCHED_DELIMITERS_ENABLED
:julia_unpaired_parentheses
elseif !RAINBOW_DELIMITERS_ENABLED[]
elseif !RAINBOW_DELIMITERS_ENABLED
:julia_parentheses
else
displaydepth = mod1(pdepth, MAX_PAREN_HIGHLIGHT_DEPTH)

0 comments on commit da6f7aa

Please sign in to comment.