]> git.eshelyaron.com Git - sweep.git/commitdiff
* (sweeprolog-beginning-of-predicate-at-point): fix hang near bob
authorEshel Yaron <me@eshelyaron.com>
Sat, 10 Dec 2022 06:28:44 +0000 (08:28 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 10 Dec 2022 06:28:44 +0000 (08:28 +0200)
sweeprolog-tests.el
sweeprolog.el

index eb08bcc8b45f4f8f040a5b6b3dd93124af941d6f..cf0d331151d43f79ad39ff72f87aa7fe230cbfbd 100644 (file)
@@ -587,7 +587,7 @@ foo.
 foo :- Body.
 "))))
 
-(ert-deftest dwim-next-clause-module-qualified-cdg ()
+(ert-deftest dwim-next-clause-module-qualified-dcg ()
   "Tests inserting new module-qualified DCG non-terminal."
   (let ((temp (make-temp-file "sweeprolog-test"
                               nil
@@ -1020,6 +1020,15 @@ scasp_and_show(Q, Model, Tree) :-
     (sweeprolog-end-of-top-term)
     (should (= (point) 252))))
 
+(ert-deftest beginning-of-predicate-definition-near-bob ()
+  "Test finding the beginning of the first predicate definition."
+  (with-temp-buffer
+    (sweeprolog-mode)
+    (insert "foo :- bar.")
+    (goto-char (point-min))
+    (sweeprolog-beginning-of-predicate-at-point)
+    (should (= (point) (point-min)))))
+
 (ert-deftest align-spacs-in-line-comment ()
   "Test using `sweeprolog-align-spaces' in a line comment."
   (with-temp-buffer
index 2161dc5aef9523402bbd07f5342122eec15c6e42..9fabeb028083516ba2bdee8f042fa529ab77f2c0 100644 (file)
@@ -2962,7 +2962,8 @@ predicate definition at or directly above POINT."
       (while (and point (not (bobp)))
         (sweeprolog-beginning-of-top-term)
         (backward-char 1)
-        (if-let* ((ndef (sweeprolog-definition-at-point (point)))
+        (if-let* ((moved (< (point) point))
+                  (ndef (sweeprolog-definition-at-point (point)))
                   (nfun (cadr ndef))
                   (nari (caddr ndef))
                   (same (and (string= fun nfun)