diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index d97347268..978a0f850 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -1748,18 +1748,16 @@ func setTaskDatesFromCurrentDateRepeat(oldTask, newTask *Task) { } var ( - checklistTiptapCheckedRegex = regexp.MustCompile(`(data-checked=")true(")`) - checklistInputCheckedRegex = regexp.MustCompile(`(]*type=["']checkbox["'][^>]*?)\s+checked(?:=["'][^"']*["'])?`) - checklistMarkdownCheckedRegex = regexp.MustCompile(`(?m)^(\s*[-*]\s+\[)[xX](\])`) + checklistTiptapCheckedRegex = regexp.MustCompile(`(data-checked=")true(")`) + checklistInputCheckedRegex = regexp.MustCompile(`(]*type=["']checkbox["'][^>]*?)\s+checked(?:=["'][^"']*["'])?`) ) -// resetDescriptionChecklist unchecks every checklist item in a description without -// touching any other content. A recurring task carries its description verbatim into -// the next occurrence, so checked checklist items would otherwise stay checked. +// resetDescriptionChecklist unchecks every checklist item in a TipTap HTML description +// (descriptions are always stored as HTML, never markdown) without touching other content, +// so a recurring task's next occurrence does not inherit checked items. func resetDescriptionChecklist(description string) string { description = checklistTiptapCheckedRegex.ReplaceAllString(description, "${1}false${2}") description = checklistInputCheckedRegex.ReplaceAllString(description, "$1") - description = checklistMarkdownCheckedRegex.ReplaceAllString(description, "$1 $2") return description } diff --git a/pkg/models/tasks_test.go b/pkg/models/tasks_test.go index ca24a35cf..433bee18a 100644 --- a/pkg/models/tasks_test.go +++ b/pkg/models/tasks_test.go @@ -1006,21 +1006,6 @@ func TestUpdateDone(t *testing.T) { assert.True(t, newTask.DueDate.After(oldTask.DueDate)) assert.Equal(t, unchecked, newTask.Description) }) - t.Run("reset markdown checklist on recurrence", func(t *testing.T) { - oldTask := &Task{ - Done: false, - RepeatAfter: 8600, - DueDate: time.Unix(1550000000, 0), - } - newTask := &Task{ - Done: true, - Description: "- [x] one\n- [X] two\n- [ ] three\nnot a [x] checklist", - } - - updateDone(oldTask, newTask) - - assert.Equal(t, "- [ ] one\n- [ ] two\n- [ ] three\nnot a [x] checklist", newTask.Description) - }) t.Run("non-recurring description untouched", func(t *testing.T) { const checked = `before
Item
after`