Decides which of several notes referencing the same attachment owns it.
An attachment referenced from more than one note has no single correct home, so collecting it falls back to whatever collectAttachmentUsedByMultipleNotesMode says — skip, copy, cancel, or ask. A priority list lets the user answer the question once instead: put .md above .excalidraw and an image shared by both lands in the markdown note’s folder.
A tie is deliberately NOT resolved here. Two notes of equal priority is exactly the ambiguity the existing mode setting already exists to handle, and inventing a second, silent rule for it would move a file the user never named.
The tie is also the whole of what gets REPORTED. A note the list ranked below the best rank cannot resolve the ambiguity, so listing it only adds noise — and worse in a picker, where offering it invites an answer the priority list itself would not have given. That is why filterHighestPriorityNotePaths exists alongside the two functions that decide.
| Function | Description |
|---|
| filterHighestPriorityNotePaths | Narrows the referencing notes to the ones sharing the best rank. Those notes are the whole of the ambiguity: one the list ranked below them cannot resolve anything, so reporting it only adds noise. This mirrors pickHighestPriorityNotePath’s conditions rather than re-deciding anything, so the two can only ever agree — whenever that names a winner, this returns exactly that one note. A list that decides nothing at all — empty, or matching no note — ranks every note NO_PRIORITY_MATCH, so they all tie and every one of them is kept. That is the same list the user saw before, which is correct: nothing has ruled any of them out. |
| findNoPriorityWinnerReason | Explains why the priority list named no owner for an attachment. Only meaningful once pickHighestPriorityNotePath has returned null (or the list was empty and was never consulted); it mirrors that function’s own conditions rather than re-deciding anything, so the two can only ever agree. |
| findNotePriorityRank | Finds how highly a note ranks in the priority list. An entry matches in one of four ways, picked by its shape so that one list can express all of them: - property:name — the note’s frontmatter has name; property:name=value also compares the value. - /regular expression/ — tested against the note’s path. - .ext — the note’s path ends with it, case-insensitively. This is the form the request asked for. - anything else — a path from the vault root, matching the vocabulary of the include / exclude path settings. When a note matches several entries the longest one decides its rank, so the most specific entry wins and the order of the list is left to express priority. Without this an Excalidraw note could never rank below a plain markdown one: drawing.excalidraw.md also ends with .md, so .md above .excalidraw.md — the very example the request is built on — would tie instead of resolving. Equal-length matches fall to the earlier entry. |
| pickHighestPriorityNotePath | Picks the single highest-priority note among those referencing an attachment. Returns null when the best rank is shared by more than one note, or when no note matches anything. Both are ties, and a tie is the caller’s problem: it is what the multiple-notes mode setting is for. |
| Enum | Description |
|---|
| NoPriorityWinnerReason | Why the priority list did not settle which note owns an attachment. The three values are exactly the three ways pickHighestPriorityNotePath (plus its empty-list guard) can fail to name a winner, so a caller can tell the user the real reason instead of only reporting that the attachment is referenced by several notes. |
| Variable | Description |
|---|
| NO_PRIORITY_MATCH | The rank of a note that matches no entry in the priority list. Higher than any real rank, so a note that matches nothing always loses to one that matches something. |