Repository navigation
refactor(core)!: ask leaf for the heading under the caret instead of parsing the body again - #5
Merged
Conversation
…parsing the body again `DocumentSession::heading_at_caret` parsed the body through twig a second time because leaf had no way to answer the question. leaf now has `Doc::heading_at_caret`, and provui's lock already carries it, so the session asks the tree leaf holds for the body. leaf builds that tree lazily, so the question needs `&mut`. BREAKING CHANGE: `DocumentSession::heading_at_caret` and `locator_at_caret` take `&mut self`, and `reference_here` takes `&mut DocumentSession`. Behavioural-change: A heading's `text` is its words with the inline markup stripped, as leaf gives them: `## The *hard* part` reads as `The hard part`, and a same-document link from `reference_here` is labelled that way. The locator slug is unchanged.
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.
What changed
DocumentSession::heading_at_caretnow delegates to leaf'sDoc::heading_at_caretand no longer parses the body through twig a second time. leaf builds its node tree lazily, soheading_at_caret,locator_at_caretandreference_herenow take the session by&mut. provui-tui'sNav::reference_hereandshow_referencefollow.Why
This is provui's half of leaf's task
heading-at-offset. The leaf half (Doc::heading_at/heading_at_caret) has landed, and provui's lock (712f12e) already carries it. The task is done when provui's second parse is gone.twigis already out ofprovui-core's manifest.Behavioural change
A heading's
textis now leaf's: the words with the inline markup stripped.## The *hard* partreads asThe hard part, notThe *hard* part. A same-document link fromreference_heregets that label too. The#locatorslug is the same as before.Closing the task
The task file lives in leaf, so this PR can't mark it done. Once this PR merges, the task can be shelved in leaf (
org shelve) with this PR's merge commit named.Verification
the_heading_above_the_caret_is_what_a_locator_namesnow asserts the sub-heading's text and span. It failed onmain("The *hard* part"vs"The hard part") and passes with the change.ship ci: all 6 jobs pass (fmt, clippy -D warnings, tests, docs, package isolation, MSRV).