licht1stein / obsidian.el

Obsidian Notes for Emacs
GNU General Public License v3.0
376 stars 27 forks source link

obsidian-follow-link-at-point shouldn't offer a multiple selections of files with the same suffix searched #64

Closed mastro35 closed 1 year ago

mastro35 commented 1 year ago

Hi, I think I found a bug.

In my vault I have two files named aaa.md and not-the-aaa.md. If in a third file called xxx.md I put a link to [aaa](aaa.md) and I follow it with obsidian-follow-link-at-point, I am not redirected to aaa.md but I'm promped so to choose which file to follow because I have two files with the same suffix aaa.md in my directory.

I think this shouldn't happen, a link should bring me to a specific file.

I think this happens because of this function:

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

that match the files using the suffix, while it should probably use the full file name like this:

(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))

What do you think about it?

mastro35 commented 1 year ago

Fixed