aboutsummaryrefslogtreecommitdiff
path: root/tests/test-ui-navigation-split-follow-undo-kill.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-12 11:32:53 -0500
committerCraig Jennings <c@cjennings.net>2026-06-12 11:32:53 -0500
commitc6260735749d29dda254361427c613572a2c6a65 (patch)
tree8f9ae11662bb6470bbf70c8af40555dcd66463a3 /tests/test-ui-navigation-split-follow-undo-kill.el
parent8c713514d1a09f800141194b59fb276978d5da88 (diff)
downloaddotemacs-c6260735749d29dda254361427c613572a2c6a65.tar.gz
dotemacs-c6260735749d29dda254361427c613572a2c6a65.zip
fix(ui-navigation): error clearly when undo-kill prefix exceeds the list
An out-of-range numeric prefix made (nth (1- arg) ...) return nil, and find-file on nil signaled a wrong-type-argument. Guard the index and raise a user-error naming how many killed files are available. A new test covers the out-of-range path.
Diffstat (limited to 'tests/test-ui-navigation-split-follow-undo-kill.el')
-rw-r--r--tests/test-ui-navigation-split-follow-undo-kill.el13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test-ui-navigation-split-follow-undo-kill.el b/tests/test-ui-navigation-split-follow-undo-kill.el
index b1d990208..8e3900743 100644
--- a/tests/test-ui-navigation-split-follow-undo-kill.el
+++ b/tests/test-ui-navigation-split-follow-undo-kill.el
@@ -102,5 +102,18 @@ non-visited entry, not the second."
(cj/undo-kill-buffer 0))
(should-not opened)))
+(ert-deftest test-ui-navigation-undo-kill-buffer-out-of-range-arg-errors ()
+ "Error: a prefix larger than the killed-file list signals a clear user-error,
+not a wrong-type-argument from find-file on nil."
+ (let ((opened nil)
+ (recentf-mode t)
+ (recentf-list '("/tmp/a.org")))
+ (cl-letf (((symbol-function 'require) (lambda (&rest _) t))
+ ((symbol-function 'recentf-mode) (lambda (&rest _) t))
+ ((symbol-function 'buffer-list) (lambda (&rest _) nil))
+ ((symbol-function 'find-file) (lambda (f) (setq opened f))))
+ (should-error (cj/undo-kill-buffer 5) :type 'user-error))
+ (should-not opened)))
+
(provide 'test-ui-navigation-split-follow-undo-kill)
;;; test-ui-navigation-split-follow-undo-kill.el ends here