Ebonsignori / obsidian-at-symbol-linking

Adds ability to link with @ in Obsidian. Can limit @ linking to specific folders e.g. People/
MIT License
60 stars 9 forks source link

[Bug] Selecting alias of the same name as the contact filename from popup list enters link to `[[contact]]` not `[[contact|contact]]` #32

Open redactedscribe opened 4 months ago

redactedscribe commented 4 months ago

Describe the bug

If I have a contact file named @bob and it also has aliases: [ "@bob" ], typing the characters @bo into a note shows the suggestions popup list with two @bobs listed, only one with an arrow next to it indicating that it's an alias. Selecting the alias link to @bob from this list enters [[@bob]] into the note when it should be entering [[@bob|@bob]].

If the alias was something else, e.g. "@bob2", then selecting the alias link to @bob would enter [[@bob|@bob2]]. It seems the plugin is choosing to ignore entering the alias if it's identical to the contact filename when arguably this shouldn't be happening, hence a bug report rather than a feature request. I'm picking the alias @bob after all, not the @bob note which is also listed in the popup.

So far I've been linking via wikilink syntax instead of using the @ symbol: Typing [[@bo suggests the alias @Bob and correctly enters [[@bob|@bob]].

To Reproduce Steps to reproduce the behavior:

  1. Create a contact named @bob.
  2. Give it an alias of "@bob".
  3. Link to bob: Type @bo, select the @bob alias link (has an arrow next to it).
  4. Result is [[@bob]] not [[@bob|@bob]].

Expected behavior

[[@bob|@bob]].

Screenshots -

In case it matters, I have the "Include @ symbol" option disabled for the plugin.

Aha. This looks to be related to #14, which was fixed, but the fix was too broad it seems. If "Include @ symbol" is disabled, it shouldn't prevent an alias of the same name being entered, i.e. [[@bob|@bob]]. If "Include @ symbol" is disabled and there is no "@bob" alias, just enter [[@bob]]. If "Include @ symbol" is enabled, we'd also expect [[@bob|@bob]], even when the file doesn't specify an "@bob" alias.

Thanks.

redactedscribe commented 4 months ago

To be clear, even if the filename is A and its alias is A (i.e. no @s involved), selecting the alias link from the popup list which @ triggers simply enters [[A]], not [[A|A]].