branch: externals/hyperbole
commit 092c65c75c9845787dcd2262a917d777b1de40ad
Merge: 2a83f378a3 db9f64b348
Author: bw <r...@gnu.org>
Commit: bw <r...@gnu.org>

    Merge branch 'master' into rsw
---
 ChangeLog            | 15 +++++++++
 test/hywiki-tests.el | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 101 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 427a782f0c..4f01410a2d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-06-06  Mats Lidell  <ma...@gnu.org>
+
+* test/hywiki-tests.el (hywiki-tests--wikiword-yanked-with-extra-words):
+    Failing test for yanked in WikiWord.
+
+2025-06-05  Mats Lidell  <ma...@gnu.org>
+
+* test/hywiki-tests.el (hywiki-tests--hywiki-face-region-at): Get overlay
+    at pos bounding box.
+    (hywiki-tests--word-n-face-at): Use
+    hywiki-tests--hywiki-face-region-at for verifying WikiWord and overlay
+    matches.
+    (hywiki-tests--verify-removal-of-delimiter-updates-face): Add failing
+    test where WikiWord and overlay does not match.
+
 2025-06-02  Bob Weiner  <r...@gnu.org>
 
 * hyrolo.el (hyrolo-kill): Add consult completion support.
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index bccffc4574..09644e18e5 100644
--- a/test/hywiki-tests.el
+++ b/test/hywiki-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell
 ;;
 ;; Orig-Date:    18-May-24 at 23:59:48
-;; Last-Mod:     27-May-25 at 02:14:49 by Bob Weiner
+;; Last-Mod:      5-Jun-25 at 00:24:12 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1305,11 +1305,23 @@ See gh#rswgnu/hyperbole/669."
         (hy-delete-file-and-buffer wiki-page)
         (hy-delete-dir-and-buffer hywiki-directory)))))
 
+(defun hywiki-tests--hywiki-face-region-at (&optional pos)
+  "Get the start and end of the hywiki--word-face overlay at POS or point.
+Return nil if at no hywiki--word-face overlay."
+  (let ((overlays (overlays-at (or pos (point))))
+        result)
+    (when overlays
+      (dolist (overlay overlays result)
+        (when (equal (overlay-get overlay 'face) 'hywiki--word-face)
+          (cl-assert (not result) "There can only be one overlay with 
`hywiki--word-face'")
+          (setq result (cons (overlay-start overlay) (overlay-end 
overlay))))))))
+
 (defun hywiki-tests--word-n-face-at ()
   "Non-nil if at a WikiWord and it has `hywiki--word-face'."
   (cl-destructuring-bind (word beg end) (hywiki-word-at :range)
     (when word
       (when (hy-test-word-face-at-region beg end)
+        (should (equal (hywiki-tests--hywiki-face-region-at beg) (cons beg 
end)))
         word))))
 
 (defvar hywiki-tests--with-face-test nil
@@ -1576,6 +1588,79 @@ Insert test in the middle of other text."
         (hy-delete-files-and-buffers (list hywiki-page 
hywiki-page-with-section))
         (hy-delete-dir-and-buffer hywiki-directory)))))
 
+(ert-deftest hywiki-tests--verify-removal-of-delimiter-updates-face ()
+  "Verify removing a delimiter the face is changed along with the WikiWord."
+  :expected-result :failed
+  (hywiki-tests--preserve-hywiki-mode
+    (let* ((hywiki-directory (make-temp-file "hywiki" t))
+           (wikiHi (cdr (hywiki-add-page "Hi")))
+           (hywiki-tests--with-face-test t))
+      (unwind-protect
+          (progn
+            (hywiki-mode 1)
+            (dolist (testcase
+                     '((("\"Hi#a b c\"") (p3 . "Hi#a b c") (p11) (-1) (p3 . 
"Hi#a") (p10) ("\"") (p3 . "Hi#a b c"))
+                       (("(Hi#s n)" . "Hi#s n") (-1) (p3 . "Hi#s") (p8) (")" . 
"Hi#s n"))))
+              (with-temp-buffer
+                (hywiki-tests--run-test-case testcase))))
+        (hy-delete-file-and-buffer wikiHi)
+        (hy-delete-dir-and-buffer hywiki-directory)))))
+
+(ert-deftest hywiki-tests--wikiword-yanked-with-extra-words ()
+  "Verify that a WikiWord that is yanked in highlights properly."
+  :expected-result :failed
+  (hywiki-tests--preserve-hywiki-mode
+    (let* ((hywiki-directory (make-temp-file "hywiki" t))
+           (wikiHi (cdr (hywiki-add-page "Hi")))
+           (wikiHo (cdr (hywiki-add-page "Ho")))
+           (hywiki-tests--with-face-test t))
+      (unwind-protect
+          (progn
+            (hywiki-mode 1)
+            ;; Non WikiWords in front of WikiWord.
+            (with-temp-buffer
+              (let ((kill-ring (list "a b Hi#c"))
+                    interprogram-paste-function)
+                (yank))
+              (goto-char 1)
+              (hywiki-tests--verify-hywiki-word nil)
+              (goto-char 6)
+              (hywiki-tests--verify-hywiki-word "Hi#c"))
+            ;; Non WikiWords after WikiWord.
+            (with-temp-buffer
+              (let ((kill-ring (list "Hi#a b c"))
+                    interprogram-paste-function)
+                (yank))
+              (goto-char 2)
+              (hywiki-tests--verify-hywiki-word "Hi#a"))
+            ;; Multiple WikiWords with non WikiWords.
+            (with-temp-buffer
+              (let ((kill-ring (list "a Hi#b c Ho#d e"))
+                    interprogram-paste-function)
+                (yank))
+              (goto-char 4)
+              (hywiki-tests--verify-hywiki-word "Hi#b")
+              (goto-char 11)
+              (hywiki-tests--verify-hywiki-word "Ho#d"))
+            ;; Right part of WikiWord yanked in.
+            (with-temp-buffer
+              (insert "H")
+              (let ((kill-ring (list "i#s"))
+                    interprogram-paste-function)
+                (yank))
+              (goto-char 2)
+              (hywiki-tests--verify-hywiki-word "Hi#s"))
+            ;; Left part of WikiWord yanked in.
+            (with-temp-buffer
+              (insert "i#s")
+              (goto-char 1)
+              (let ((kill-ring (list "H"))
+                    interprogram-paste-function)
+                (yank))
+              (hywiki-tests--verify-hywiki-word "Hi#s")))
+        (hy-delete-files-and-buffers (list wikiHi wikiHo))
+        (hy-delete-dir-and-buffer hywiki-directory)))))
+
 (provide 'hywiki-tests)
 
 ;; This file can't be byte-compiled without the `el-mock' package

Reply via email to