From 326bffaa2f555f863abb7a9cc0887c86779ea97b Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 5 May 2026 04:13:01 -0500 Subject: fix: don't create zero-width overlay for hint-less clozes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit org-drill-hide-cloze-hints checked (null (match-beginning 2)) to detect "no hint present," but the cloze regex's hint group is an empty-allowed alternation — the group always participates in the match, so match-beginning is always a position, never nil. For a card like "[Paris]" (no hint), the function fell through to org-drill-hide-region with start = end and made a zero-width overlay. Cosmetically harmless but accumulates one stray overlay per hint-less cloze. On a buffer with many such cards the tracking cost is real. Switched the guard to (= (match-beginning 2) (match-end 2)) — empty match. Found while writing tests; locked in by tests/test-org-drill-hide-show.el's test-org-drill-hide-cloze-hints-no-hint-no-overlay. --- org-drill.el | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/org-drill.el b/org-drill.el index c3a73eb..e2234e5 100644 --- a/org-drill.el +++ b/org-drill.el @@ -2043,13 +2043,19 @@ Saves current settings and applies drill-specific display preferences." ""))))))) (defun org-drill-hide-cloze-hints () - "Hide cloze hints." + "Hide cloze hints. + +The cloze regex's hint group is `\\(\\|HINTSEP.+?\\)' — an empty +alternation — so it always participates in the match. Check for an +empty match (start = end) rather than nil match-beginning, otherwise +this function creates a zero-width overlay for every hint-less cloze." (save-excursion (while (re-search-forward org-drill-cloze-regexp nil t) (unless (or (save-match-data (org-drill-pos-in-regexp (match-beginning 0) org-link-bracket-re 1)) - (null (match-beginning 2))) ; hint subexpression matched + ;; Empty match → no hint present, nothing to hide. + (= (match-beginning 2) (match-end 2))) (org-drill-hide-region (match-beginning 2) (match-end 2)))))) (defmacro org-drill-with-replaced-entry-text (text &rest body) -- cgit v1.2.3