Repository navigation
fix(star): place star before Obsidian Tasks metadata
Problem
DataviewTask.addStar appended the star to the end of the task line:
lines[taskLineIdx] = lines[taskLineIdx] + " ⭐";The Obsidian Tasks plugin parses its signifiers from the end of the line. A trailing ⭐ makes it stop early and absorb the last field into the description, so that field is silently dropped from Tasks queries:
- [ ] Write docs 🆔 abc123 ⛔ def456 ⭐ ← Tasks loses ⛔ def456
This is what @Octaeon reported in #475 (metadata emojis suddenly rendering in a query for starred tasks) and matches the "state gets lost" symptom in #267.
Fix
The star now goes at the end of the description, in front of the first Tasks signifier or Dataview inline field:
- [ ] Write docs ⭐ 🆔 abc123 ⛔ def456
TASKS_SIGNIFIERS/TASKS_METADATA_START_PATTERNintask-regex.tslocate where the trailing metadata block starts. Dataview inline fields ([id:: …],(dependsOn:: …)) count as metadata; brackets in the description (Read [book] later) and the checkbox itself do not.addStarToTaskLinestrips any existing star before re-inserting, so it is idempotent and repairs lines written by earlier versions.addSignToTaskInFilenormalizes the star position after writing a sign. Without this, adding a dependency to a note that still has a legacy trailing star would reproduce the original bug on an already-broken line — existing vaults now heal as tasks are edited.removeStarFromTaskLinereplaces a.trim()that was stripping the leading indentation of nested tasks.
Notes
The star remains a Tasks Map concept, so it still shows up as part of the description in Tasks queries — that is inherent to storing extra metadata on a - [ ] … line and is unchanged here. This PR only stops it from destroying other fields.
NoteTask is unaffected; it stores starred in frontmatter.
Testing
- New unit tests for
addStarToTaskLine,removeStarFromTaskLine, andnormalizeStarPositionInTaskLinecovering each signifier type, Dataview fields, tags, nested indentation, idempotency, and legacy repositioning. - Updated
DataviewTaskstar tests to assert exact output rather than "contains ⭐". - Regression test for the legacy trailing star in
addSignToTaskInFile. - Full suite: 326 passed.
npm run buildandnpm run lintclean.
🤖 Generated with Claude Code