         
         // just clear current highlight and return if no coloring needs
         guard self.style.hasHighlightDefinition else {
-            self.apply(highlights: [:], range: highlightRange)
+            self.textStorage.apply(highlights: [:], range: highlightRange)
             completionHandler()
             return nil
         }

}


extension NSAttributedString.Key {
    
    static let syntaxType = NSAttributedString.Key("CotEditor.SyntaxType")
}

        
        // use cache if the content of the whole document is the same as the last
        if let cache = self.highlightCache, cache.styleName == self.style.name, cache.string == self.textStorage.string {
            self.textStorage.apply(highlights: cache.highlights, range: wholeRange)
            completionHandler()
            return nil
        }
