diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-20 23:31:59 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-20 23:31:59 -0500 |
| commit | 3ea207c1c7588fbc122a766e5d8381815cd44711 (patch) | |
| tree | a52cc9bf88f4248254e4b133200fda4fd3e27336 /modules/jumper.el | |
| parent | 4c06b26b6b4f399e3d45f00c281f24a33a15cc66 (diff) | |
| download | dotemacs-3ea207c1c7588fbc122a766e5d8381815cd44711.tar.gz dotemacs-3ea207c1c7588fbc122a766e5d8381815cd44711.zip | |
fix(jumper): handle empty completing-read input without crashing
An unmatched choice made the assoc lookup nil, which crashed the index arithmetic with wrong-type-argument. The jump prompt now gives a user-error and the remove prompt cancels.
Diffstat (limited to 'modules/jumper.el')
| -rw-r--r-- | modules/jumper.el | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/jumper.el b/modules/jumper.el index 1fbd1293..bfafe08b 100644 --- a/modules/jumper.el +++ b/modules/jumper.el @@ -194,6 +194,10 @@ Returns: \\='no-locations if no locations stored, locations)) (choice (completing-read "Jump to: " locations nil t)) (idx (cdr (assoc choice locations)))) + ;; A UI that permits empty input (no vertico) yields a choice with no + ;; entry; nil would crash the index arithmetic downstream. + (unless idx + (user-error "No matching location")) (jumper--do-jump-to-location idx) (message "Jumped to location"))))) @@ -230,7 +234,8 @@ Returns: \\='no-locations if no locations stored, (jumper--location-candidates)) (locations (cons (cons "Cancel" -1) locations)) (choice (completing-read "Remove location: " locations nil t)) - (idx (cdr (assoc choice locations)))) + ;; Empty input (no matching entry) cancels, same as picking Cancel. + (idx (or (cdr (assoc choice locations)) -1))) (pcase (jumper--do-remove-location idx) ('cancelled (message "Operation cancelled")) ('t (message "Location removed")))))) |
