From de10d69543c5ebd3a5bd603a0f6be221be493cae Mon Sep 17 00:00:00 2001 From: IdanL Date: Mon, 4 Nov 2024 00:04:06 +0200 Subject: [PATCH] issue mitigated --- main.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/main.ts b/main.ts index 3489ffe..7f71711 100644 --- a/main.ts +++ b/main.ts @@ -90,7 +90,6 @@ export default class RedirectPlugin extends Plugin { const targetNoteName = currentFileContent.match(linkTextRegex)?.at(1); if (!targetNoteName) { - console.info("No redirect syntax found."); return null; } const targetNoteFile = this.app.metadataCache.getFirstLinkpathDest( @@ -135,23 +134,23 @@ export default class RedirectPlugin extends Plugin { // Turn off event handler to avoid opening the target note twice this.app.workspace.off("file-open", this.redirectRef); - await this.app.workspace.openLinkText( - redirectingNoteInFolder.name, - redirectingNoteInFolder.path, - this.settings.openInNewTab, - { active: this.settings.switchToNewTab } - ); + await this.app.workspace + .getLeaf(this.settings.openInNewTab) + .openFile(redirectingNoteInFolder, { + active: this.settings.switchToNewTab, + }); + this.app.workspace.getLeaf().detach(); this.app.workspace.on("file-open", this.redirectRef); } await this.deleteNote(redirectingNote); } catch (error) { - console.warn(error); + console.error(error); } } - private async deleteNote(orgRedirectingNote: TFile): Promise { + private async deleteNote(orgRedirectingNote: TFile): Promise { try { await this.app.vault.delete(orgRedirectingNote); } catch (error) {