fix: templated occurrence filename counts as representing the title - #2248
Open
raphaelfaouakhiri wants to merge 2 commits into
Open
Conversation
…allumalpass#2246) With storeTitleInFilename enabled, occurrences named by the occurrence filename template were always born with the title property, because the titleIsRepresentedByFilename check compared the unique filename against the plain title — which a templated name never matches. The title property then wins over the filename when reading, so every view showed the occurrence without its period suffix. Compare against the generated occurrence filename instead when the template was used. Collision suffixes and sanitization losses still preserve the title property, keeping the intent of the collision handling fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2246
Problem
With
storeTitleInFilenameenabled, occurrences materialized through the occurrence filename template (#2126 / #2134) are always created with the title property in frontmatter: thetitleIsRepresentedByFilenamecheck (from the collision handling fix) compares the unique filename against the plain title, and a templated name likePay rent — 2026-09never matches it. Since the title property takes precedence over the filename when reading, every view then shows the occurrence without its period suffix — defeating the purpose of the template.Fix
When the occurrence filename template was used, compare the unique filename against the generated occurrence filename instead of the plain title. If the templated name was used as-is, it represents the title and the property is omitted (display falls back to the filename, suffix included) — the same rule regular tasks already follow when filename == title.
The intent of the collision handling fix is preserved:
Pay rent — 2026-09-1) → title property is kept;Pay: rent→Pay rent) → title property is kept.One behavior worth noting: editing the title of an already-materialized occurrence writes the title property back (title ≠ filename again), which is correct and consistent with the collision handling.
Tests
New
tests/unit/issues/issue-2246-occurrence-template-title-frontmatter.test.ts(3 cases: template used as-is omits title; collision suffix keeps it; sanitization keeps it). First case written before the fix and observed failing.Verified no regressions in
tests/unit/servicesand the issue-1623/2107 suites; the 2 failures intask-occurrence-materialization.test.ts("advances completion-anchored parents") andICSNoteService.folder-template.test.tsfail identically on currentmainwithout this change (date-dependent / pre-existing).🤖 Generated with Claude Code