chhoumann / quickadd

QuickAdd for Obsidian
https://quickadd.obsidian.guide
MIT License
1.53k stars 136 forks source link

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

Open FynnFreyer opened 1 year ago

FynnFreyer commented 1 year ago

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

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

FynnFreyer commented 1 year ago

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.