1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-04 22:50:59 -08:00

Don't skip widgets when moving backward

* 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.
This commit is contained in:
Mauro Aranda 2021-01-04 10:02:20 -03:00
parent 65f21729e6
commit 4e80eb7b7c
2 changed files with 21 additions and 1 deletions

View 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)))

View 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