From cbb3b89c25cd49f9f6d05e69e067dde168346de1 Mon Sep 17 00:00:00 2001 From: Johannes Lund Date: Mon, 25 Aug 2014 13:54:09 +0200 Subject: [PATCH] Don't create new typingAttributes in -setTheme --- Chromatism/Chromatism/JLTextView.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Chromatism/Chromatism/JLTextView.m b/Chromatism/Chromatism/JLTextView.m index fc7025f..121437b 100644 --- a/Chromatism/Chromatism/JLTextView.m +++ b/Chromatism/Chromatism/JLTextView.m @@ -96,11 +96,14 @@ - (void)setSyntaxTokenizer:(JLTokenizer *)tokenizer -(void)setTheme:(JLTokenizerTheme)theme { - self.syntaxTokenizer.colors = [Chromatism colorsForTheme:theme]; - self.typingAttributes = @{ NSForegroundColorAttributeName : self.syntaxTokenizer.colors[JLTokenTypeText]}; _theme = theme; - //Set font, text color and background color back to default + // Set font- and background color from the theme + self.syntaxTokenizer.colors = [Chromatism colorsForTheme:theme]; + NSMutableDictionary *typingAttributes = self.typingAttributes.mutableCopy; + typingAttributes[NSForegroundColorAttributeName] = self.syntaxTokenizer.colors[JLTokenTypeText]; + self.typingAttributes = typingAttributes; + UIColor *backgroundColor = self.syntaxTokenizer.colors[JLTokenTypeBackground]; [self setBackgroundColor:backgroundColor ? backgroundColor : [UIColor whiteColor] ];