Skip to content

Commit

Permalink
obsidian--match-files finds all files with given basename & more
Browse files Browse the repository at this point in the history
When issue licht1stein#64 was opened, obsidian--match-files was lazy,
only the suffix was checked, so it found for 'aa.md' both
'aa.md' and 'baa.md'. Its solution broke the relative file name
usage (e.g. [[aa.md]] was "found" in the inbox).

To cover both use case the match needs to be either exact
(relative to the vault root), or partial, where the searched
file name prefixed with '/' is searched with s-ends-with-p.

Fixes issue licht1stein#72.
  • Loading branch information
LA-Toth committed Oct 19, 2023
1 parent d02c3e7 commit 786c315
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion obsidian.el
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ Argument S relative file name to clean and convert to absolute."

(defun obsidian--match-files (f all-files)
"Filter ALL-FILES to return list with same name as F."
(-filter (lambda (el) (s-equals-p f (obsidian--file-relative-name el))) all-files))
(-filter (lambda (el) (or (s-equals-p f el) (s-ends-with-p (concat "/" f) el))) all-files))

(defun obsidian--prepare-new-file-from-rel-path (p)
"Create file if it doesn't exist and return full system path for relative path P.
Expand Down

0 comments on commit 786c315

Please sign in to comment.