]> git.eshelyaron.com Git - sweep.git/commitdiff
FIXED: sweeprolog-beginning-of-next-top-term: other possible loop
authorEshel Yaron <me@eshelyaron.com>
Tue, 22 Nov 2022 10:59:41 +0000 (12:59 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 22 Nov 2022 11:01:43 +0000 (13:01 +0200)
* sweeprolog.el (sweeprolog-beginning-of-next-top-term): don't loop
when called in the last term of the buffer
* sweeprolog-tests.el (beginning-of-next-top-term-at-last-clause): new
test case

sweeprolog-tests.el
sweeprolog.el

index ed79c425f3eeec3db65f8f5944c3080abb0aa02f..f096bf743b57ecbcd806bac081b82bbd0215f126 100644 (file)
@@ -657,6 +657,24 @@ loop_term(I, Arity, Goal1, Goal2) :-
     (sweeprolog-end-of-top-term)
     (should (= (point) 232))))
 
+(ert-deftest beginning-of-next-top-term-at-last-clause ()
+  "Test finding the beginning of next top term when there isn't one."
+  (with-temp-buffer
+    (sweeprolog-mode)
+    (insert "
+test_bindings(Name-Value) -->
+    ['    '~w = ~p'-[Name-Value] ]..
+")
+    (goto-char 43)
+    (backward-delete-char 1)
+    (end-of-line)
+    (backward-delete-char 1)
+    (should (string= (buffer-string) "
+test_bindings(Name-Value) -->
+    ['    ~w = ~p'-[Name-Value] ].
+"
+                     ))))
+
 
 (defun sweeprolog-test-indentation (given expected)
   (with-temp-buffer
index 2fcabbfa98f831d7d8bbae1bb0f73248a5417aae..d1c585bd8fed30bfa25833786e510f21648fafa8 100644 (file)
@@ -2485,9 +2485,9 @@ Interactively, POINT is set to the current point."
       (re-search-forward (rx bol graph) nil t)
       (while (and (or (nth 8 (syntax-ppss))
                       (looking-at-p (rx bol (or "%" "/*"))))
-                  (not (eobp)))
-        (re-search-forward (rx bol graph) nil t)))
-    (beginning-of-line)
+                  (not (eobp))
+                  (re-search-forward (rx bol graph) nil t))))
+    (unless (= p (point)) (beginning-of-line))
     (not (= p (point)))))
 
 (defun sweeprolog-end-of-top-term ()