Repository navigation
fix: reference short and bracket-leading tasks in snippets - #2128
Merged
zefhemel merged 5 commits intoSep 18, 2026
Merged
Conversation
The snippet task-reference regex required the task body to start with two non-`[` characters, so a task whose body was one or two characters long, or that opened with a markdown link or an attribute, never got its `[[Page@pos]]` reference injected. Without that reference a task shown in a Linked Mentions widget cannot be toggled: the widget writes state back only through a parent wiki link containing `@`. Replace the two-character lookahead with a negative lookahead for `[[`, which is what "already has a page reference" actually means.
Adds the bracket-past-first-character, leading-transclusion, marker/state, deeper-indent, multi-task offset and whitespace-only body cases, plus three controls: a body opening with two brackets is still skipped, and a trailing carriage return still is.
With more than one space before an existing `[[page@pos]]` reference the greedy separator gave one back, the body then started with a space rather than `[[`, and the task was referenced a second time. The already-referenced check now looks past leading spaces.
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.
Summary
extractSnippetinjects a[[Page@pos]]reference into nested task lines so a task shown in a Linked Mentions / Linked Tasks widget stays toggleable. Its regex demanded the task body begin with two non-[characters plus at least one more.* [ ] Hi), or whose body opens with a single[(a markdown link[Google](…), an attribute[due: 2026-01-01]), never got the reference and cannot be toggled from the widget.[[". This change says that directly:([^[][^[].+)→((?!\[\[).+).plugs/index/snippet.ts.plugs/index/snippet.test.tsnow holds 13 tests: 2 pre-existing, 3 from the fix commit, 8 added by an independent adversarial verification pass. 8 of the 13 fail on base; the other 5 are the 2 pre-existing tests and 3 declared controls.Both arms at the current head
37c30cee, verbatim:Decisions
Minimal focused fix; alternatives and boundaries are documented in the change rationale and regression coverage.
Not run: full cross-platform/manual integration matrix; scoped regression and relevant static checks were run as recorded above.
AI assistance: this bug was found and the fix and tests were drafted with AI tooling in my workflow; the tests and checks above were executed as pasted. I'm responsible for the change and will handle review feedback.