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,7 +7,6 @@
// //
import AppKit import AppKit
import Combine
class JavaScriptEditorView: NSTextView { class JavaScriptEditorView: NSTextView {
@ -25,9 +24,6 @@ class JavaScriptEditorView: NSTextView {
} }
} }
private let rehighlightSubject = PassthroughSubject<Void, Never>()
private var debouncedRehighlightCancellable: AnyCancellable!
func rehighlight() { func rehighlight() {
isRehighlighting = true isRehighlighting = true
highlighter.highlight(attributed: self.textStorage!) highlighter.highlight(attributed: self.textStorage!)
@ -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()
} }
} }