]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't skip widgets when moving backward
authorMauro Aranda <maurooaranda@gmail.com>
Mon, 4 Jan 2021 13:02:20 +0000 (10:02 -0300)
committerMauro Aranda <maurooaranda@gmail.com>
Mon, 4 Jan 2021 13:02:20 +0000 (10:02 -0300)
* lisp/wid-edit.el (widget-move): Remove code that caused
widget-backward to skip an immediate previous widget when moving
backward from the start of a widget.  (Bug#45623)

* test/lisp/wid-edit-tests.el (widget-test-widget-backward): New test.

lisp/wid-edit.el
test/lisp/wid-edit-tests.el

index f920130226e73bcc3b2e30e3ef567793ed49e057..8b10d71dcb318883061c25d5be0e6d897fb07e4a 100644 (file)
@@ -1204,7 +1204,6 @@ This is much faster.")
 ARG may be negative to move backward.
 When the second optional argument is non-nil,
 nothing is shown in the echo area."
-  (or (bobp) (> arg 0) (backward-char))
   (let ((wrapped 0)
        (number arg)
        (old (widget-tabable-at)))
index 35235c656658e7731d13b207b17821846ff6cb7b..17fdfefce84c79a644e35b2352db80e6c97ac9fe 100644 (file)
@@ -301,4 +301,25 @@ return nil, even with a non-nil bubblep argument."
       (should child)
       (should (equal (widget-value widget) '((1 "One")))))))
 
+(ert-deftest widget-test-widget-move ()
+  "Test moving with `widget-forward' and `widget-backward'."
+  (with-temp-buffer
+    (dolist (el '("First" "Second" "Third"))
+      (widget-create 'push-button el))
+    (widget-insert "\n")
+    (use-local-map widget-keymap)
+    (widget-setup)
+    (goto-char (point-min))
+    ;; Check that moving from the widget's start works.
+    (widget-forward 2)
+    (should (string= "Third" (widget-value (widget-at))))
+    (widget-backward 1)
+    (should (string= "Second" (widget-value (widget-at))))
+    ;; Check that moving from inside the widget works.
+    (goto-char (point-min))
+    (widget-forward 2)
+    (forward-char)
+    (widget-backward 1)
+    (should (string= "Second" (widget-value (widget-at))))))
+
 ;;; wid-edit-tests.el ends here