@@ -405,6 +405,7 @@ const FACES = let default = Dict{Symbol, Face}(
405405 :bright_white => (r = 0xf6 , g = 0xf5 , b = 0xf4 ))
406406 (; default, basecolors,
407407 current = ScopedValue (copy (default)),
408+ modifications = ScopedValue (Dict {Symbol, Face} ()),
408409 lock = ReentrantLock ())
409410end
410411
@@ -451,6 +452,7 @@ function resetfaces!()
451452 for (key, val) in FACES. default
452453 current[key] = val
453454 end
455+ empty! (FACES. modifications[])
454456 current
455457 end
456458end
@@ -467,6 +469,7 @@ it is deleted, a warning message is printed, and `nothing` returned.
467469function resetfaces! (name:: Symbol )
468470 @lock FACES. lock if ! haskey (FACES. current[], name)
469471 elseif haskey (FACES. default, name)
472+ delete! (FACES. modifications[], name)
470473 FACES. current[][name] = copy (FACES. default[name])
471474 else # This shouldn't happen
472475 delete! (FACES. current[], name)
@@ -656,9 +659,16 @@ Face (sample)
656659```
657660"""
658661function loadface! ((name, update):: Pair{Symbol, Face} )
659- @lock FACES. lock if haskey (FACES. current[], name)
660- FACES. current[][name] = merge (FACES. current[][name], update)
661- else
662+ @lock FACES. lock begin
663+ mface = get (FACES. modifications[], name, nothing )
664+ if ! isnothing (mface)
665+ update = merge (mface, update)
666+ end
667+ FACES. modifications[][name] = update
668+ cface = get (FACES. current[], name, nothing )
669+ if ! isnothing (cface)
670+ update = merge (cface, update)
671+ end
662672 FACES. current[][name] = update
663673 end
664674end
0 commit comments