Fix: restore token highlighting in Quick Add field (regression)

A fast-path early-return added in the voice-binding fix
(`if tv.textColor == .label && tv.text == text && editing { return }`) skipped
rebuilding the attributed text while editing — so token highlights never
reapplied as the parser updated highlightRanges on each keystroke. Removed it so
highlights always render. Also switched the highlight tint from systemBlue to the
app accent (orange) to match the established design.

Verified on simulator: "Remind me to pray everyday" → "Remind me to" + "everyday"
highlighted in accent orange; chips Today / Daily.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
kutesir
2026-06-24 21:36:21 +03:00
parent c9f0fd0777
commit b6c9f5b0ca

View File

@@ -1778,18 +1778,18 @@ struct NLTaskField: UIViewRepresentable {
}
return
}
// Avoid clobbering the live UITextView (and the cursor) when the displayed
// text already matches the binding.
if tv.textColor == .label && tv.text == text && editing { return }
// Always rebuild the attributed text so token highlights stay live as the
// parser updates highlightRanges on each keystroke. (A fast-path early-return
// here previously suppressed highlighting while editing.)
let sel = tv.selectedRange
let attr = NSMutableAttributedString(string: text)
let full = NSRange(location: 0, length: attr.length)
attr.addAttributes([.font: UIFont.systemFont(ofSize: 18), .foregroundColor: UIColor.label], range: full)
let highlight = UIColor(AppColors.accent)
for r in highlightRanges where r.location + r.length <= attr.length {
attr.addAttributes([
.backgroundColor: UIColor.systemBlue.withAlphaComponent(0.13),
.foregroundColor: UIColor.systemBlue,
.backgroundColor: highlight.withAlphaComponent(0.18),
.foregroundColor: highlight,
], range: r)
}
tv.attributedText = attr