Skip to content

Commit

Permalink
Fix inline metadata not recognized if not in first line (#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunyatasattva authored May 1, 2024
1 parent e242fa3 commit 61f5b1c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/parsers/helpers/hydrateBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 61f5b1c

Please sign in to comment.