diff --git a/src/parsers/helpers/hydrateBoard.ts b/src/parsers/helpers/hydrateBoard.ts index 64fbce3d..a8262b86 100644 --- a/src/parsers/helpers/hydrateBoard.ts +++ b/src/parsers/helpers/hydrateBoard.ts @@ -49,19 +49,21 @@ export function hydrateItem(stateManager: StateManager, item: Item) { const firstLineEnd = item.data.title.indexOf('\n'); const inlineFields = extractInlineFields(item.data.title, true); + if (inlineFields?.length) { - const inlineMetadata = (item.data.metadata.inlineMetadata = - firstLineEnd > 0 - ? inlineFields.filter((f) => taskFields.has(f.key) && f.end < firstLineEnd) - : inlineFields); + const inlineMetadata = (item.data.metadata.inlineMetadata = inlineFields.reduce((acc, curr) => { + if (!taskFields.has(curr.key)) acc.push(curr); + else if (firstLineEnd <= 0 || curr.end < firstLineEnd) acc.push(curr); + + return acc; + }, [])); const moveTaskData = stateManager.getSetting('move-task-metadata'); const moveMetadata = stateManager.getSetting('move-inline-metadata'); if (moveTaskData || moveMetadata) { let title = item.data.title; - for (let i = inlineMetadata.length - 1; i >= 0; i--) { - const item = inlineMetadata[i]; + for (const item of [...inlineMetadata].reverse()) { const isTask = taskFields.has(item.key); if (isTask && !moveTaskData) continue;