From 4e80eb7b7ce76e02fa0b2b0fa66223f29e3f6bcd Mon Sep 17 00:00:00 2001 From: Mauro Aranda Date: Mon, 4 Jan 2021 10:02:20 -0300 Subject: [PATCH] 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. --- lisp/wid-edit.el | 1 - test/lisp/wid-edit-tests.el | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index f920130226e..8b10d71dcb3 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -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))) diff --git a/test/lisp/wid-edit-tests.el b/test/lisp/wid-edit-tests.el index 35235c65665..17fdfefce84 100644 --- a/test/lisp/wid-edit-tests.el +++ b/test/lisp/wid-edit-tests.el @@ -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 -- 2.39.5