Skip to content

Commit 265e19a

Browse files
committed
fix(vertico): +vertico/jump-list failing to jump
Prior to this fix this command would error out because of incorrect expectations wrt consult--read's return value.
1 parent 277a376 commit 265e19a

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

modules/completion/vertico/autoload/vertico.el

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -201,34 +201,39 @@ If INITIAL is non-nil, use as initial input."
201201
(nreverse
202202
(delete-dups
203203
(delq
204-
nil (mapcar (lambda (mark)
205-
(when mark
206-
(cl-destructuring-bind (path pt _id) mark
207-
(let ((buf (get-file-buffer path)))
208-
(unless buf
209-
(push (setq buf (find-file-noselect path t))
210-
buffers))
211-
(with-current-buffer buf
212-
(goto-char pt)
213-
(font-lock-fontify-region (line-beginning-position) (line-end-position))
214-
(cons (format "%s:%d: %s"
215-
(buffer-name)
216-
(line-number-at-pos)
217-
(string-trim-right (or (thing-at-point 'line) "")))
218-
(point-marker)))))))
219-
(cddr (better-jumper-jump-list-struct-ring
220-
(better-jumper-get-jumps (better-jumper--get-current-context))))))))
204+
nil (mapcar
205+
(lambda (mark)
206+
(when mark
207+
(cl-destructuring-bind (path pt _id) mark
208+
(let* ((visiting (find-buffer-visiting path))
209+
(buf (or visiting (find-file-noselect path t)))
210+
(dir default-directory))
211+
(unless visiting
212+
(push buf buffers))
213+
(with-current-buffer buf
214+
(goto-char pt)
215+
(font-lock-fontify-region
216+
(line-beginning-position) (line-end-position))
217+
(format "%s:%d: %s"
218+
(car (cl-sort (list (abbreviate-file-name (buffer-file-name buf))
219+
(file-relative-name (buffer-file-name buf) dir))
220+
#'< :key #'length))
221+
(line-number-at-pos)
222+
(string-trim-right (or (thing-at-point 'line) ""))))))))
223+
(cddr (better-jumper-jump-list-struct-ring
224+
(better-jumper-get-jumps (better-jumper--get-current-context))))))))
221225
:prompt "jumplist: "
222226
:sort nil
223227
:require-match t
224228
:category 'jump-list))
225229
(mapc #'kill-buffer buffers))))
226-
(let ((mark (cdr jump)))
227-
(delq! (marker-buffer mark) buffers)
228-
(mapc #'kill-buffer buffers)
229-
(setq buffers nil)
230-
(with-current-buffer (switch-to-buffer (marker-buffer mark))
231-
(goto-char (marker-position mark)))))
230+
(if (not (string-match "^\\([^:]+\\):\\([0-9]+\\): " jump))
231+
(user-error "No match")
232+
(let ((file (match-string-no-properties 1 jump))
233+
(line (match-string-no-properties 2 jump)))
234+
(find-file file)
235+
(goto-char (point-min))
236+
(forward-line (string-to-number line)))))
232237

233238
;;;###autoload
234239
(defun +vertico/embark-which-key-indicator ()

0 commit comments

Comments
 (0)