JavaScript Highlighter: batch attributed string updates to vastly improve

performance
This commit is contained in:
Shadowfacts 2020-04-06 19:31:35 -04:00
父節點 c89d6d5f39
當前提交 d353fabd69
簽署人: shadowfacts
GPG 金鑰 ID: 94A5AB95422746E5
共有 1 個檔案被更改,包括 3 行新增0 行删除

查看文件

@ -73,6 +73,7 @@ class JavaScriptHighlighter {
}
func highlight() {
attributed.beginEditing()
let fullRange = NSRange(location: 0, length: attributed.length)
attributed.setAttributes([
.foregroundColor: NSColor.textColor,
@ -83,6 +84,8 @@ class JavaScriptHighlighter {
while let char = peek(), !expressionEnds.contains(char) {
consumeExpression()
}
attributed.endEditing()
}
private func emit(token: TokenType, range: NSRange) {