From c24190141da32abef40ab74ad8f3eaab26edf421 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Tue, 26 Sep 2023 23:30:42 +0200 Subject: [PATCH] ; Fix off-by-one in end of next token position for parentheses * sweeprolog.el (sweeprolog-next-token-boundaries): Return correct end of token position for parentheses. * sweeprolog-tests.el (up-list): New test. --- sweeprolog-tests.el | 13 +++++++++++++ sweeprolog.el | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/sweeprolog-tests.el b/sweeprolog-tests.el index 09f711f..06f9ec2 100644 --- a/sweeprolog-tests.el +++ b/sweeprolog-tests.el @@ -1770,4 +1770,17 @@ f:o(Bar) --> baz(Bar)." (forward-line) (should (string= (add-log-current-defun) "f:o//1"))) +(sweeprolog-deftest up-list () + "Test `up-list' support." + " +foo((A,B)) => + ( bar(-!-A) + ; baz(B) + ). +" + (call-interactively #'up-list) + (should (= (point) 30)) + (call-interactively #'up-list) + (should (= (point) 51))) + ;;; sweeprolog-tests.el ends here diff --git a/sweeprolog.el b/sweeprolog.el index cfc524a..a17253f 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -4277,11 +4277,11 @@ work." (forward-char -1)) (list 'operator beg (if (= beg (point)) end (point))))) ((= syn ?\() - (list 'open beg (point))) + (list 'open beg (1+ beg))) ((= syn ?\)) - (list 'close beg (point))) + (list 'close beg (1+ beg))) ((= syn ?>) nil) - (t (list 'else beg (point))))))))) + (t (list 'else beg (1+ beg))))))))) (defun sweeprolog-last-token-boundaries (&optional pos) (let ((point (or pos (point))) -- 2.39.2