JavaScript Highlighter: batch attributed string updates to vastly improve
performance
This commit is contained in:
parent
c89d6d5f39
commit
d353fabd69
|
@ -73,6 +73,7 @@ class JavaScriptHighlighter {
|
||||||
}
|
}
|
||||||
|
|
||||||
func highlight() {
|
func highlight() {
|
||||||
|
attributed.beginEditing()
|
||||||
let fullRange = NSRange(location: 0, length: attributed.length)
|
let fullRange = NSRange(location: 0, length: attributed.length)
|
||||||
attributed.setAttributes([
|
attributed.setAttributes([
|
||||||
.foregroundColor: NSColor.textColor,
|
.foregroundColor: NSColor.textColor,
|
||||||
|
@ -83,6 +84,8 @@ class JavaScriptHighlighter {
|
||||||
while let char = peek(), !expressionEnds.contains(char) {
|
while let char = peek(), !expressionEnds.contains(char) {
|
||||||
consumeExpression()
|
consumeExpression()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attributed.endEditing()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func emit(token: TokenType, range: NSRange) {
|
private func emit(token: TokenType, range: NSRange) {
|
||||||
|
|
Loading…
Reference in New Issue