quickadd icon indicating copy to clipboard operation
quickadd copied to clipboard

[BUG] QuickAdd does not respect "New link format" Setting when appending links

Open FynnFreyer opened this issue 2 years ago • 2 comments

Description

Under Settings → Files & Links, you can set the link format, to e.g. only insert relative links. QuickAdd does not follow this setting and inserts a vault absolute (I think) link instead.

Reproduce

  1. Go to Settings → Files & Links
  2. Set "New link format" to "relative"
  3. Insert a Template with the option "Append link" set
  4. Inspect the link, it is not relative

Expected behavior

QuickAdd should honor the "New link format" setting.

Screenshots

QuickAdd_BugReport_1

New link format is set to relative.

QuickAdd_BugReport_2

Append link is set.

QuickAdd_BugReport_3

The inserted (not relative) link.

Additional information

  • OS: Fedora 37
  • QuickAdd Version: 0.8.0
  • Obsidian Version: 1.1.9

If I should provide more debug info, please let me know, also thanks a lot for the great plugin!

FynnFreyer avatar Jan 08 '23 11:01 FynnFreyer

This is super weird btw, because the relevant code (I think) uses Obsidians generateMarkdownLink which should take user preferences into account by default.

if (this.choice.appendLink) {
const markdownLink = this.app.fileManager.generateMarkdownLink(
	file,
	""
);
appendToCurrentLine(markdownLink, this.app);

But the behaviour is still wrong. Maybe something interferes, or it gets the 'relative' link from the vault root, because that's where the working directory is or whatever.

FynnFreyer avatar Jan 09 '23 09:01 FynnFreyer

I can confirm this bug is occurring to me as well. Hope a fix is on way. Thx

joellti avatar Apr 13 '25 22:04 joellti

Thank you for the detailed bug report! I can confirm this is a valid issue.

The problem is that when calling generateMarkdownLink(), we're passing an empty string "" as the sourcePath parameter. According to the Obsidian API, this parameter should be the path of the source file (where the link will be inserted). Without this information, Obsidian can't calculate relative paths and defaults to absolute paths.

Took a lot to fix, and there might still be edge-cases to handle. But I've fixed it in #958, which will be available in the next release. Would you be able to test if it works as expected then? Thank you!

chhoumann avatar Oct 12 '25 09:10 chhoumann

Very cool. Will take a look soon. If you don't hear back, you can assume everything to be working fine for me =D @chhoumann

FynnFreyer avatar Oct 12 '25 18:10 FynnFreyer

Thank you! Expecting to release 2.6.0 early next week, which will have the fix. :)

chhoumann avatar Oct 12 '25 18:10 chhoumann

:tada: This issue has been resolved in version 2.6.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Oct 16 '25 16:10 github-actions[bot]