emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-30 d509a356997: Fix regression in widget-move (bug#72995)


From: Stephen Berman
Subject: emacs-30 d509a356997: Fix regression in widget-move (bug#72995)
Date: Sat, 14 Sep 2024 06:43:00 -0400 (EDT)

branch: emacs-30
commit d509a35699738519d42a35d72827b1111425669c
Author: Stephen Berman <stephen.berman@gmx.net>
Commit: Stephen Berman <stephen.berman@gmx.net>

    Fix regression in widget-move (bug#72995)
    
    * lisp/wid-edit.el (widget-move): Avoid advancing point only if it
    is at the start of a widget at BOB.
    
    * test/lisp/wid-edit-tests.el (widget-test-widget-move-bug72995): New test.
---
 lisp/wid-edit.el            |  5 ++++-
 test/lisp/wid-edit-tests.el | 17 +++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index e7e6351fcab..77e506960a2 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1336,7 +1336,10 @@ nothing is shown in the echo area."
     (let ((new (widget-tabable-at)))
       (while (and (eq (widget-tabable-at) new) (not (bobp)))
        (backward-char)))
-    (unless (bobp) (forward-char)))
+    ;; If the widget is at BOB, point is already at the widget's
+    ;; starting position; otherwise, advance point to put it at the
+    ;; start of the widget (cf. bug#69943 and bug#72995).
+    (unless (and (widget-tabable-at) (bobp)) (forward-char)))
   (unless suppress-echo
     (widget-echo-help (point)))
   (run-hooks 'widget-move-hook))
diff --git a/test/lisp/wid-edit-tests.el b/test/lisp/wid-edit-tests.el
index d416eb99022..03e7e5a7b7d 100644
--- a/test/lisp/wid-edit-tests.el
+++ b/test/lisp/wid-edit-tests.el
@@ -344,6 +344,23 @@ return nil, even with a non-nil bubblep argument."
     (should (string= "Third" (widget-value (widget-at))))
     (widget-forward 1)))  ; Should not signal beginning-of-buffer error.
 
+(ert-deftest widget-test-widget-move-bug72995 ()
+  "Test moving to a widget that starts at buffer position 2."
+  (with-temp-buffer
+    ;; The first tabable widget begins at position 2 (bug#72995).
+    (widget-insert " ")
+    (dolist (el '("First" "Second" "Third"))
+      (widget-create 'push-button el))
+    (widget-insert "\n")
+    (use-local-map widget-keymap)
+    (widget-setup)
+    ;; Make sure there is no tabable widget at BOB.
+    (goto-char (point-min))
+    (should-not (widget-tabable-at))
+    ;; Check that we can move to the first widget after BOB.
+    (widget-forward 1)
+    (should (widget-tabable-at))))
+
 (ert-deftest widget-test-color-match ()
   "Test that the :match function for the color widget works."
   (let ((widget (widget-convert 'color)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]