pvojtechovsky / obsidian-link-with-alias

Obsidian plugin for handy creation of links and alias in front matter of target document
MIT License
35 stars 1 forks source link

[BUG] Link text is overwritten when using markdown links #22

Open jayemar opened 6 days ago

jayemar commented 6 days ago

Describe the bug If using markdown links instead of wiki links, selecting text and creating a link using "Link with alias" overwrites the selected text with the link itself instead of using the selected text as the link text.

To Reproduce Steps to reproduce the behavior:

  1. Go to Settings -> Files and links -> and disable "Use [[Wikilinks]]"
  2. Go to Settings -> Community plugins -> Link with alias -> click the gear cog and unselect "Copy selected text as link file"
  3. From with a note, select some text and then run command "Link with alias: create link with alias".
  4. You should now be inside of a newly created link with auto complete enabled to input a link. Start typing to select a note to link to. When you select a note, the highlighted text will be replaced with the link for the selected note, replacing the highlighted text.

Expected behavior Everything works as expected until item 4 above. When I select a note, I expect that note to be used as the link inside the parentheses of the new markdown link, and the highlighted text to be used as the link text within the square brackets.

Screenshots If applicable, add screenshots to help explain your problem.

Additional Information Current example: highlighted text -> my note file

Expected: highlighted text -> highlighted text

pvojtechovsky commented 1 day ago

Thanks for reporting. I was able to reproduce this problem.

I am quite busy with other stuff, so I have no time to fix it soon. If anybody is willing to have a look and fix it then here https://github.com/pvojtechovsky/obsidian-link-with-alias/blob/050bdbed1b29c2e38591f88eec914f40f414a54c/src/main.ts#L236 is the place which should be checked.

Note: I never tried to switch off Wiki links. I like wiki links so it fits to my purposes. Therefore it is not urgent problem for me and has no priority for me. Anyway I confirm that it is bug, which should be solved and I will welcome a related pull request and I want to provide some technical support to fix the problem if needed.