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() consumeDotLookup()
} else if char == "?" { } else if char == "?" {
consumeTernaryExpression() consumeTernaryExpression()
} else if expressionEnds.contains(char) {
return
} else { } else {
consume() consume()
} }

View File

@ -7,13 +7,12 @@
// //
import AppKit import AppKit
import Combine
class JavaScriptEditorView: NSTextView { class JavaScriptEditorView: NSTextView {
var highlighter = JavaScriptHighlighter() var highlighter = JavaScriptHighlighter()
private var isRehighlighting = false private var isRehighlighting = false
override var string: String { override var string: String {
get { get {
super.string super.string
@ -24,9 +23,6 @@ class JavaScriptEditorView: NSTextView {
rehighlight() rehighlight()
} }
} }
private let rehighlightSubject = PassthroughSubject<Void, Never>()
private var debouncedRehighlightCancellable: AnyCancellable!
func rehighlight() { func rehighlight() {
isRehighlighting = true isRehighlighting = true
@ -38,13 +34,6 @@ class JavaScriptEditorView: NSTextView {
super.awakeFromNib() super.awakeFromNib()
textStorage!.delegate = self 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 { override func shouldChangeText(in affectedCharRange: NSRange, replacementString: String?) -> Bool {
@ -128,6 +117,6 @@ extension JavaScriptEditorView: NSTextStorageDelegate {
} }
} }
rehighlightSubject.send() rehighlight()
} }
} }