Browse Source

JavaScript Highlighter: batch attributed string updates to vastly improve

performance
master
Shadowfacts 2 months ago
parent
commit
d353fabd69
Signed by: Shadowfacts <me@shadowfacts.net> GPG Key ID: 94A5AB95422746E5
1 changed files with 3 additions and 0 deletions
  1. 3
    0
      MongoView/Synax Highlighting/JavaScriptHighlighter.swift

+ 3
- 0
MongoView/Synax Highlighting/JavaScriptHighlighter.swift View File

@@ -73,6 +73,7 @@ class JavaScriptHighlighter {
73 73
     }
74 74
     
75 75
     func highlight() {
76
+        attributed.beginEditing()
76 77
         let fullRange = NSRange(location: 0, length: attributed.length)
77 78
         attributed.setAttributes([
78 79
             .foregroundColor: NSColor.textColor,
@@ -83,6 +84,8 @@ class JavaScriptHighlighter {
83 84
         while let char = peek(), !expressionEnds.contains(char) {
84 85
             consumeExpression()
85 86
         }
87
+
88
+        attributed.endEditing()
86 89
     }
87 90
     
88 91
     private func emit(token: TokenType, range: NSRange) {

Loading…
Cancel
Save