Compare commits

..

No commits in common. "aef05153a220b4518a681edfcbd2f4f555f847bf" and "6b39e90ea4f4675d248668e8fce4c1c6f1f4a315" have entirely different histories.

2 changed files with 4 additions and 13 deletions

View File

@ -225,6 +225,8 @@ class JavaScriptHighlighter {
consumeDotLookup()
} else if char == "?" {
consumeTernaryExpression()
} else if expressionEnds.contains(char) {
return
} else {
consume()
}

View File

@ -7,13 +7,12 @@
//
import AppKit
import Combine
class JavaScriptEditorView: NSTextView {
var highlighter = JavaScriptHighlighter()
private var isRehighlighting = false
override var string: String {
get {
super.string
@ -24,9 +23,6 @@ class JavaScriptEditorView: NSTextView {
rehighlight()
}
}
private let rehighlightSubject = PassthroughSubject<Void, Never>()
private var debouncedRehighlightCancellable: AnyCancellable!
func rehighlight() {
isRehighlighting = true
@ -38,13 +34,6 @@ class JavaScriptEditorView: NSTextView {
super.awakeFromNib()
textStorage!.delegate = self
typingAttributes = [
.font: NSFont.monospacedSystemFont(ofSize: 13, weight: .regular),
.foregroundColor: NSColor.textColor
]
debouncedRehighlightCancellable = rehighlightSubject.throttle(for: .milliseconds(40), scheduler: RunLoop.main, latest: false).sink(receiveValue: rehighlight)
}
override func shouldChangeText(in affectedCharRange: NSRange, replacementString: String?) -> Bool {
@ -128,6 +117,6 @@ extension JavaScriptEditorView: NSTextStorageDelegate {
}
}
rehighlightSubject.send()
rehighlight()
}
}