From 124c851989a5f363f11b0c45d340ffe7a7e69866 Mon Sep 17 00:00:00 2001 From: SebastianMC <23032356+SebastianMC@users.noreply.github.com> Date: Thu, 14 Dec 2023 17:28:22 +0100 Subject: [PATCH] #119 - Non-string value of sorting-spec: prevents the custom sorting from working w/o error message - added a bit of defensive programming to fix the problem. The sorting spec with broken syntax is ignored (error is swallowed) --- src/main.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index e9218cd..fcdbd88 100644 --- a/src/main.ts +++ b/src/main.ts @@ -154,7 +154,8 @@ export default class CustomSortPlugin extends Plugin { aFile.path === `${this.settings.additionalSortspecFile}.md` // when user configured Inbox/sort ) { const sortingSpecTxt: string = mCache.getCache(aFile.path)?.frontmatter?.[SORTINGSPEC_YAML_KEY] - if (sortingSpecTxt) { + // Warning: newer Obsidian versions can return objects as well, hence the explicit check for string value + if (typeof sortingSpecTxt === 'string') { anySortingSpecFound = true this.sortSpecCache = processor.parseSortSpecFromText( sortingSpecTxt.split('\n'),