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.
This commit is contained in:
Henrik Lissner 2021-08-21 03:29:13 -04:00
parent 277a376b43
commit 265e19a405

View file

@ -201,21 +201,25 @@ If INITIAL is non-nil, use as initial input."
(nreverse (nreverse
(delete-dups (delete-dups
(delq (delq
nil (mapcar (lambda (mark) nil (mapcar
(lambda (mark)
(when mark (when mark
(cl-destructuring-bind (path pt _id) mark (cl-destructuring-bind (path pt _id) mark
(let ((buf (get-file-buffer path))) (let* ((visiting (find-buffer-visiting path))
(unless buf (buf (or visiting (find-file-noselect path t)))
(push (setq buf (find-file-noselect path t)) (dir default-directory))
buffers)) (unless visiting
(push buf buffers))
(with-current-buffer buf (with-current-buffer buf
(goto-char pt) (goto-char pt)
(font-lock-fontify-region (line-beginning-position) (line-end-position)) (font-lock-fontify-region
(cons (format "%s:%d: %s" (line-beginning-position) (line-end-position))
(buffer-name) (format "%s:%d: %s"
(car (cl-sort (list (abbreviate-file-name (buffer-file-name buf))
(file-relative-name (buffer-file-name buf) dir))
#'< :key #'length))
(line-number-at-pos) (line-number-at-pos)
(string-trim-right (or (thing-at-point 'line) ""))) (string-trim-right (or (thing-at-point 'line) ""))))))))
(point-marker)))))))
(cddr (better-jumper-jump-list-struct-ring (cddr (better-jumper-jump-list-struct-ring
(better-jumper-get-jumps (better-jumper--get-current-context)))))))) (better-jumper-get-jumps (better-jumper--get-current-context))))))))
:prompt "jumplist: " :prompt "jumplist: "
@ -223,12 +227,13 @@ If INITIAL is non-nil, use as initial input."
:require-match t :require-match t
:category 'jump-list)) :category 'jump-list))
(mapc #'kill-buffer buffers)))) (mapc #'kill-buffer buffers))))
(let ((mark (cdr jump))) (if (not (string-match "^\\([^:]+\\):\\([0-9]+\\): " jump))
(delq! (marker-buffer mark) buffers) (user-error "No match")
(mapc #'kill-buffer buffers) (let ((file (match-string-no-properties 1 jump))
(setq buffers nil) (line (match-string-no-properties 2 jump)))
(with-current-buffer (switch-to-buffer (marker-buffer mark)) (find-file file)
(goto-char (marker-position mark))))) (goto-char (point-min))
(forward-line (string-to-number line)))))
;;;###autoload ;;;###autoload
(defun +vertico/embark-which-key-indicator () (defun +vertico/embark-which-key-indicator ()