diff options
| -rw-r--r-- | pearl.el | 14 | ||||
| -rw-r--r-- | tests/test-pearl-comment-editing.el | 24 |
2 files changed, 27 insertions, 11 deletions
@@ -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 |
