From becb603f20a210d805d5d99151935f36ff1759f2 Mon Sep 17 00:00:00 2001 From: putzwasser Date: Thu, 20 Oct 2022 16:46:15 +0200 Subject: [PATCH] Fixes creating multipne `cards-deck` lines for newly created cards This tries to fix the creation of multiple `cards-deck` YAML/frontmatter lines during the process of adding new flash cards to anki. This is more like a hotfix as I'm not sure if it solves the problem bug completely. --- src/services/cards.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/services/cards.ts b/src/services/cards.ts index 238ea86..f9a4eb5 100644 --- a/src/services/cards.ts +++ b/src/services/cards.ts @@ -230,6 +230,10 @@ export class CardsService { let newFrontmatter = ""; const cardsDeckLine = `cards-deck: ${deckName}\n`; if (frontmatter) { + if (deckName === obsidian.parseFrontMatterEntry(frontmatter, "cards-deck")) { + console.log('Skipping frontmatter update, as there is no change in cards-deck'); + return; + } const oldFrontmatter: string = this.file.substring( frontmatter.position.start.offset, frontmatter.position.end.offset