Skip to content

Commit

Permalink
Merge pull request #41 from hrehfeld/fix-find-file-single
Browse files Browse the repository at this point in the history
fix: obisidian-find-file: jump to a single match (instead of creating a new file)
  • Loading branch information
licht1stein authored Apr 20, 2023
2 parents 171e7cf + 6e8984a commit 4bd737a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions obsidian.el
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,12 @@ Argument S relative file name to clean and convert to absolute."
"Take file F and either opens directly or offer choice if multiple match."
(let* ((all-files (->> (obsidian-list-all-files) (-map #'obsidian--file-relative-name)))
(matches (obsidian--match-files f all-files))
(file (if (> (length matches) 1)
(let* ((choice (completing-read "Jump to: " matches)))
choice)
f)))
(file (cl-case (length matches)
(0 f)
(1 (car matches))
(t
(let* ((choice (completing-read "Jump to: " matches)))
choice)))))
(-> file obsidian--expand-file-name find-file)))

(defun obsidian-wiki-link-p ()
Expand Down

0 comments on commit 4bd737a

Please sign in to comment.