Task with subtasks is not created correctly in MD #12

Closed
opened 2026-06-10 17:17:54 +02:00 by fpindado · 1 comment
Owner

When you create a task with subtasks in SP the sync create just a list of tasks (tasks and subtasks) not indenting the subtasks.

When you create a task with subtasks in SP the sync create just a list of tasks (tasks and subtasks) not indenting the subtasks.
Author
Owner

Fixed in v0.1.2 (commit 3eefaf7).

Root cause: in mergeSpIntoExistingFile (SP→MD write-back), a subtask added in SP under a parent that was already present in the file arrived "alone" in the append step (the parent isn't new), so convertTasksToMarkdown rendered it as a flat, unindented orphan at the end of the file. Generating a brand-new file worked, which is why the existing unit tests passed — the in-place merge had no subtask coverage.

Fix:

  • New subtasks of an already-present parent are now inserted indented, directly under that parent (after its existing subtask block), ordered by the parent's subTaskIds.
  • Indentation reuses the file's actual indent unit (tab or spaces) via a new detectIndentString — the original attempt measured indent by character length and re-emitted spaces, which collapsed a tab to a single space.
  • Added regression tests for the in-place merge (new subtask under existing parent, tab indent, 1-space indent, brand-new parent appended nested).

Verified on macOS 18.9.1D: adding a subtask in SP under an existing parent now writes it indented with a tab, matching the file's existing subtasks.

Closing as fixed.

Fixed in v0.1.2 (commit 3eefaf7). **Root cause:** in `mergeSpIntoExistingFile` (SP→MD write-back), a subtask added in SP under a parent that was already present in the file arrived "alone" in the append step (the parent isn't new), so `convertTasksToMarkdown` rendered it as a flat, unindented orphan at the end of the file. Generating a brand-new file worked, which is why the existing unit tests passed — the in-place merge had no subtask coverage. **Fix:** - New subtasks of an already-present parent are now inserted **indented, directly under that parent** (after its existing subtask block), ordered by the parent's `subTaskIds`. - Indentation reuses the file's **actual indent unit** (tab or spaces) via a new `detectIndentString` — the original attempt measured indent by character length and re-emitted spaces, which collapsed a tab to a single space. - Added regression tests for the in-place merge (new subtask under existing parent, tab indent, 1-space indent, brand-new parent appended nested). **Verified on macOS 18.9.1D:** adding a subtask in SP under an existing parent now writes it indented with a tab, matching the file's existing subtasks. Closing as fixed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
fpindado/sync-md-multi#12
No description provided.