obsidianmd / obsidian-api

Type definitions for the latest Obsidian API.
https://docs.obsidian.md
MIT License
1.65k stars 192 forks source link

Bug: processFrontMatter does not work if callback deletes all keys #164

Open AndyEveritt opened 2 months ago

AndyEveritt commented 2 months ago

https://docs.obsidian.md/Reference/TypeScript+API/FileManager/processFrontMatter

[!NOTE] I am not a JS/TS developer so my terminology is likely wrong

Steps to reproduce:

await this.app.fileManager.processFrontMatter(
  sharedFile.file,
  (frontmatter) => {
    // Remove the shared link
    delete frontmatter["link"];
  }

taken from project

if link is the only field in the frontmatter object then this will not do anything. If there are other fields then the link field is correctly deleted

Expected Behaviour

The provided code would delete the link field from the frontmatter regardless of is it leaves the frontmatter empty