From b6c9f5b0ca5a15010c947bc4b1a92add6958577d Mon Sep 17 00:00:00 2001 From: kutesir Date: Wed, 24 Jun 2026 21:36:21 +0300 Subject: [PATCH] Fix: restore token highlighting in Quick Add field (regression) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- KisaniCal/Views/TodayView.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/KisaniCal/Views/TodayView.swift b/KisaniCal/Views/TodayView.swift index 83a5970..d5b402d 100644 --- a/KisaniCal/Views/TodayView.swift +++ b/KisaniCal/Views/TodayView.swift @@ -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