Skip to content

Commit

Permalink
Explicit validation after edit
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Feb 17, 2024
1 parent 5cb19c6 commit 3347619
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/SwiftTreeSitter",
"state" : {
"revision" : "10cb68c00a9963c2884b30f168a9de377790d812"
"revision" : "7ccb58219c3e928bf1938dd43d33fd349dc71808"
}
},
{
Expand Down
12 changes: 12 additions & 0 deletions Sources/Neon/TextSystemStyler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ public final class TextSystemStyler<Interface: TextSystemInterface> {
public func invalidate(_ target: RangeTarget) {
validator.invalidate(target)
}

public func validate(_ target: RangeTarget) {
let priorityRange = textSystem.visibleRange

validator.validate(target, prioritizing: priorityRange)
}

public func validate() {
let priorityRange = textSystem.visibleRange

validator.validate(.range(priorityRange), prioritizing: priorityRange)
}
}
1 change: 1 addition & 0 deletions Sources/Neon/TextViewHighlighter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ extension TextViewHighlighter: NSTextStorageDelegate {
// At this point in mutation processing, it is unsafe to apply style changes. Ideally, we'd have a hook so we can know when it is ok. But, no such system exists for stock TextKit 1/2. So, instead we just let the runloop turn. This is *probably* safe, if the text does not change again, but can also result in flicker.
DispatchQueue.main.backport.asyncUnsafe {
self.buffer.endBuffering()
self.styler.validate()
}
}
}
Expand Down

0 comments on commit 3347619

Please sign in to comment.