Repository navigation
fix: match capture header paths regardless of statistics cookies - #1141
Open
officialasishkumar wants to merge 4 commits into
Open
officialasishkumar wants to merge 4 commits into
officialasishkumar wants to merge 4 commits into
Conversation
…ok-ch#1037) A capture template's header path was compared against the raw title of each header, which includes statistics cookies such as [2/5] or [40%]. The path "Tasks" therefore never matched the header "Tasks [2/5]", and a path that spelled out the cookie stopped matching as soon as a child changed state. In-app captures were then silently dropped, and URL captures failed with "header path invalid". headerWithPath now first looks for a header whose title equals the path segment exactly, and only if there is none compares titles with all statistics cookies removed. The exact match keeps existing templates pointing at the same header when a sibling differs only by its cookie. Org mode's own heading lookup ignores statistics cookies the same way (see org-complex-heading-regexp-format).
Author
|
The red e2e jobs aren't caused by this change: they fail in the "Install Playwright Browser" step with |
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.
Fixes #1037
As a user with capture templates, when the target header carries a statistics cookie like
Tasks [2/5], I want the header pathTasksto find it, so that captures keep landing in the right place while the count changes.Problem
headerWithPathcompared every path segment with the header's raw title, cookies included. So:Tasksnever matchedTasks [2/5], andTasks [2/5], stopped matching as soon as a child changed state.When the path didn't match, an in-app capture was dropped without a message (
insertCapturePositionreturns no position). A capture from a URL failed with "header path invalid".Fix
headerWithPathfirst looks for a header whose title equals the path segment exactly, as before. Only if there is none does it compare the titles with all statistics cookies ([n/m],[n%], also empty ones) removed. This applies on every level of the path.Because the exact match comes first, existing templates keep their target, even when a sibling differs only by its cookie. Org mode's own heading lookup ignores statistics cookies in the same way (
org-complex-heading-regexp-format).The README section on header paths and the changelog mention the new behaviour.
Tests
src/lib/org_utils.unit.test.js: cookies at the start, middle and end of a title, together with a TODO keyword and tags, a changed count, cookies on nested levels, preference for the exact title, and brackets that are not cookies.e2e/tests/org-file/capture.spec.js: rename the sample'sGroceriesheader toGroceries [0/0], capture with the Groceries template (pathCapture > Groceries), and check that the new task lands below it and the cookie becomes[0/1]. The test fails on master because nothing is inserted.yarn eslint,yarn prettier-eslint --list-different,yarn test(575 tests),yarn build, and the Chromium E2E suite (63 tests) all pass locally.