VC-Dir: Fix error on `n' before "./" has appeared

If you typed `n' before "./" had appeared, Emacs signalled a
wrong-type-argument error.  Now it signals a better one.

* lisp/vc/vc-dir.el (vc-dir--before-dotname-p): Return nil if
the "./" entry hasn't appeared yet.
* test/lisp/vc/vc-tests/vc-test-misc.el
(vc-test-vc-dir-next/previous): Simulate the problem case.

* lisp/emacs-lisp/ewoc.el (ewoc-goto-next): Signal a user-error
instead of a plain error.  This makes sense for all the current
call sites.  (This is secondary to the bug fix above: this code
was never reached, previously.)
This commit is contained in:
Sean Whitton 2026-09-07 14:14:01 +01:00
parent 0ed3fa830d
commit 619a395916
3 changed files with 12 additions and 3 deletions

View file

@ -505,7 +505,7 @@ Return the node (or nil if we just passed the last node)."
;; (unless (ewoc--filter-hf-nodes ewoc node)
;; (setq node (ewoc--node-nth dll -2)))
(unless node
(error "No next"))
(user-error "No next"))
(ewoc-goto-node ewoc node)))
(defun ewoc-goto-node (ewoc node)

View file

@ -730,8 +730,10 @@ information."
;; entry, as determined by the following function. See bug#81248 for
;; further details.
(defun vc-dir--before-dotname-p ()
"Return non-nil if point is before the \"./\" entry."
(< (point) (ewoc-location (ewoc-nth vc-ewoc 0))))
"Return non-nil if point is before the \"./\" entry.
If that entry hasn't appeared yet, return nil."
(and-let* ((zeroth (ewoc-nth vc-ewoc 0)))
(< (point) (ewoc-location zeroth))))
(defun vc-dir-next-line (arg)
"Go to the next line.

View file

@ -298,6 +298,8 @@ See bug#80803 and bug#80967."
(should (equal (vc-dir-fileinfo->state data)
'edited))))))))))
;; FIXME: This test only passes once. Then there is some state left
;; behind such that it doesn't pass if run again.
(ert-deftest vc-test-vc-dir-next/previous () ; bug#81248
"Test navigating with `vc-dir-{next,previous}-{line,directory}'."
(skip-unless (executable-find vc-git-program))
@ -356,6 +358,11 @@ See bug#80803 and bug#80967."
(should (and (looking-at "\\./$") (looking-back "^ +" (pos-bol))))
(vc-dir-previous-directory)
(should (and (looking-at "\\./$") (looking-back "^ +" (pos-bol))))
;; Simulate the case in which the status lines haven't come
;; back yet. This used to give a cryptic non-`user-error'.
(goto-char (point-min))
(ewoc-filter vc-ewoc #'ignore)
(should-error (vc-dir-next-line 1) :type 'user-error)
(kill-buffer vc-dir-buf))))))
(ert-deftest vc-test-vc-dir-mark/unmark-all-dir-entry () ; bug#81249