The call HighlightingLoader.Load(xshd)
creates an IHighlightingDefinition
from the information stored in the xshd
object. If you change the xshd
later, the IHighlightingDefinition
won't know about those changes.
To fix this problem, call HighlightingLoader.Load()
only after you are done updating the highlighting:
xshd = HighlightingLoader.LoadXshd(reader);
updateStandardParametersList();
customHighlighting = HighlightingLoader.Load(xshd, HighlightingManager.Instance);
For the duplicate color exception: the expression new XshdReference<XshdColor>(existingColor)
corresponds to an XSHD color that is defined inline on the keywords element (it is a color definition, not just a reference). Thus, you have multiple definitions for the color.
To create a reference to the existing named color, use:
newKeyWords.ColorReference = new XshdReference<XshdColor>(null, "StandardParametersColor");