aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-26 16:26:39 -0500
committerCraig Jennings <c@cjennings.net>2026-05-26 16:26:39 -0500
commit80eca723d4340d0d67a709e6aef01acb935c706b (patch)
tree52ae5e845334675c7e9f2c0cada8d3f877c362e3
parent5bb933761568982b0e60621577038450bc3dc2bf (diff)
downloadpearl-80eca723d4340d0d67a709e6aef01acb935c706b.tar.gz
pearl-80eca723d4340d0d67a709e6aef01acb935c706b.zip
fix(comments): don't recolor the leading heading stars
The comment overlay started at the line beginning, so it sat on top of the leading stars. With a package like org-superstar that dims those stars (and composes a bullet from them) via a face, our overlay's face overrode it and the dimmed stars reappeared in our color, a stray "***" before the bullet. The darker, body-spanning read-only overlay made it obvious, but the overlay had covered the stars since comment highlighting first landed. I start the overlay just past the leading stars now (the point right after the `^\*+ ` match), so the stars and the bullet keep org's own fontification and only the heading text and body get our face. The highlight tests check the face on the heading text and assert the stars are left uncovered.
-rw-r--r--pearl.el14
-rw-r--r--tests/test-pearl-comment-editing.el24
2 files changed, 27 insertions, 11 deletions
diff --git a/pearl.el b/pearl.el
index 33265ef..369608d 100644
--- a/pearl.el
+++ b/pearl.el
@@ -4535,18 +4535,24 @@ highlights first."
(remove-overlays (point-min) (point-max) 'pearl-comment t)
(goto-char (point-min))
(while (re-search-forward "^\\*+ " nil t)
- (let ((comment-id (org-entry-get nil "LINEAR-COMMENT-ID")))
+ ;; Point is now just past the leading stars + space. Start the overlay
+ ;; here, not at the line beginning, so the stars (and the bullet a package
+ ;; like org-superstar composes from them) keep org's own fontification
+ ;; instead of being recolored by our face.
+ (let ((text-start (point))
+ (comment-id (org-entry-get nil "LINEAR-COMMENT-ID")))
(when comment-id
(let* ((editable (pearl--comment-editable-p
(org-entry-get nil "LINEAR-COMMENT-AUTHOR-ID")
viewer-id))
(face (if editable 'pearl-editable-comment 'pearl-readonly-comment))
- ;; Editable: heading line only, so your own comment text reads
- ;; normally. Read-only: the whole subtree, dimming the body too.
+ ;; Editable: heading text only, so your own comment reads
+ ;; normally. Read-only: through the whole subtree, dimming the
+ ;; body too.
(end (if editable
(line-end-position)
(save-excursion (org-end-of-subtree t t) (point))))
- (ov (make-overlay (line-beginning-position) end)))
+ (ov (make-overlay text-start end)))
(overlay-put ov 'pearl-comment t)
(overlay-put ov 'face face)))))))
diff --git a/tests/test-pearl-comment-editing.el b/tests/test-pearl-comment-editing.el
index b8b4af4..372cd95 100644
--- a/tests/test-pearl-comment-editing.el
+++ b/tests/test-pearl-comment-editing.el
@@ -247,15 +247,23 @@
"***** Them — 2026-05-24T10:00:00.000Z\n"
":PROPERTIES:\n:LINEAR-COMMENT-ID: c2\n:LINEAR-COMMENT-AUTHOR-ID: u-other\n:END:\ntheirs\n")
(pearl--apply-comment-highlights "u-me")
- (cl-flet ((face-on (pat)
+ (cl-flet ((face-at-text (pat)
(goto-char (point-min))
- (re-search-forward pat)
- (goto-char (line-beginning-position))
+ (re-search-forward pat) ; point lands in the heading text
(let ((ov (cl-find-if (lambda (o) (overlay-get o 'pearl-comment))
(overlays-at (point)))))
- (and ov (overlay-get ov 'face)))))
- (should (eq 'pearl-editable-comment (face-on "^\\*\\*\\*\\*\\* Me")))
- (should (eq 'pearl-readonly-comment (face-on "^\\*\\*\\*\\*\\* Them"))))))
+ (and ov (overlay-get ov 'face))))
+ (overlay-on-stars-p (pat)
+ (goto-char (point-min))
+ (re-search-forward pat)
+ (cl-find-if (lambda (o) (overlay-get o 'pearl-comment))
+ (overlays-at (line-beginning-position)))))
+ (should (eq 'pearl-editable-comment (face-at-text "^\\*\\*\\*\\*\\* Me")))
+ (should (eq 'pearl-readonly-comment (face-at-text "^\\*\\*\\*\\*\\* Them")))
+ ;; the leading stars (and the bullet org-superstar composes from them) are
+ ;; left to org's own fontification — our overlay must not cover them
+ (should-not (overlay-on-stars-p "^\\*\\*\\*\\*\\* Me"))
+ (should-not (overlay-on-stars-p "^\\*\\*\\*\\*\\* Them")))))
(ert-deftest test-pearl-highlight-readonly-comment-dims-its-body ()
"A read-only comment's body carries the grey overlay so the whole comment reads
@@ -302,11 +310,13 @@ the refresh / add-comment / view-merge paths, never on the initial render."
(save-excursion
(goto-char (point-min))
(while (re-search-forward "^\\*+ " nil t)
+ ;; point is past the leading stars, in the heading text where
+ ;; the overlay now starts
(let ((cid (org-entry-get nil "LINEAR-COMMENT-ID")))
(when cid
(let ((ov (cl-find-if
(lambda (o) (overlay-get o 'pearl-comment))
- (overlays-at (line-beginning-position)))))
+ (overlays-at (point)))))
(push (cons cid (and ov (overlay-get ov 'face))) faces))))))
;; both comment headings carry the editability overlay after a
;; plain bulk render — no refresh needed