Skip to content

Show a todo list the item a search found it by - #124

Merged
vmillet-dev merged 1 commit into
mainfrom
fix/a-todo-list-shows-what-matched
Sep 15, 2026
Merged

vmillet-dev merged 1 commit into
mainfrom
fix/a-todo-list-shows-what-matched

Conversation

@vmillet-dev

Copy link
Copy Markdown
Owner

Closes #117.

#35 gave every card the line that put it in the results. Every card except a todo
list, where the branch is unreachable:

@if (isChecklist())        → progress bar + the item layer
@else if (snippetIsCode()) → the excerpt, coloured
@else                      → the excerpt, as prose

And the items shown were picked without consulting the search: items.slice(0, 2).
So a list that matched on its fifth item showed its first two and +3 more.

A window, not a replacement

⚠️ Rendering the excerpt instead was not an option. .card-items is a sibling
layer
carrying real checkboxes — a card can be ticked without opening it, and
07-checklists drives that. The window of visible items slides to the match
instead: same order, same boxes, the card simply scrolled to the right place.

The tags do the same, so a note found by its third tag shows that tag rather than
its first two.

The trap that would have lost data

The template counts within the window; the position written back is the one in
the note. They were the same number while the window always started at zero. With
it sliding, ticking the first visible box would have ticked the first item of the
list
— a card silently editing a line the user never saw.

onItemToggle offsets by the window start, and there is a test on it in both
suites. Checked by removing the offset: red in the unit suite.

Finding the item behind a clipped excerpt

The excerpt is cut at 160 characters and gains a trailing , so a long item never
equals its own text. Matched on the prefix, with a test.

Checked locally

npm test 980 passing, npm run lint clean, npm run test:e2e 15/15 in 4:15.

🤖 Generated with Claude Code

The branch that renders a search excerpt sits behind isChecklist(), so a
list found by its fifth item showed its first two and "+3 more". Replacing
the layer with the excerpt was not an option — those are real checkboxes —
so the window of visible items slides to the match instead. The tags do
the same.

The position written back is offset by the window: the template counts
within it, and ticking the first visible box would otherwise have edited
the first item of the list.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vmillet-dev
vmillet-dev merged commit 1b1491c into main Sep 15, 2026
9 checks passed
@vmillet-dev
vmillet-dev deleted the fix/a-todo-list-shows-what-matched branch September 15, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A todo list never shows the search excerpt that explains why it matched

1 participant