Repository navigation
Let lf-code quote an excerpt under its file's own line numbers, with a Rust sort film example - #1134
Merged
Merged
Conversation
Add `indicate(owner, attribute, key)` to the widget API: a widget marks the
elements a key addresses under the widget its declared `x-refers` attribute
names, in place of what it last marked there, and `null` clears. The runtime
paints the union of every driver's elements with `data-lf-indicated` and
`aria-current="true"`, never scrolls, focuses, reveals, hydrates or announces,
and resolves standing indications again on `lf-layout`. It is browser state
like hover: nothing is logged or published. Marked experimental in its module
header and in the packages.md subsection heading.
`lf-code` answers the hook with its `hi` grammar (`lfElementsFor("3-5,8")`),
states its rendered lines with `layoutChanged`, and gives an indicated line an
accent gutter bar, number and wash, distinct from an `hi` line. marks.css
carries a zero-specificity accent outline for everything else.
Contract changes:
- One key space for x-refers verbs: `addressedElements(source, key)` resolves
the target's `lfElementsFor` hook, else a registered visual part id, else a
projected datum key. `navigateToDatum` now travels to the first element it
returns, so it also reaches visual parts and hook-addressed parts.
- `referencedProjection` resolves in the owner's own authored document first,
then the page's main, matching the server's request check (thread markup
before page). It used to search the whole document, so a page element won
over the owner's own message and another message's markup could answer.
`authoredScope` moves to passages.js beside `elementById`, which gains a
root argument.
- The undeclared-attribute TypeError is shared by both verbs
(`requireReference`).
- `data-lf-indicated` joins PAGE_PAINT_ATTRIBUTES.
- The `x-refers` $keys entry no longer claims the runtime renders every value
as a followable reference; it names the two verbs and the resolution scope.
- packages.md gains "Following a reference" (scope, key space,
navigateToDatum moved from External or derived data, and "Indicating
(experimental)"), and a behavior module's disconnect duty now includes
clearing its indication.
Tests: new tests/runtime/indication.test.mjs (scope precedence, union and
replace bookkeeping, re-resolution on lf-layout, argument errors) and
test_a_widget_indicates_lines_of_a_code_block_without_moving_the_page in
test_render_widgets.py. No existing test moved.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
`lines` on an lf-code gives the source line numbers its body quotes, in the
range grammar `hi` already speaks ("1505-1507,1520-1527"). The gutter shows
those numbers, widening to fit four digits; each gap between ranges draws an
elided row saying how many lines are left out, painted from an attribute so
it stays out of the clipboard and out of anchoring. Without `lines` a body is
lines 1..N, so a quick snippet is written and rendered as before.
Every reference into the block now names lines by those numbers: `hi`, a
note's `at`, and the key another widget indicates (#1129's lfElementsFor). A
number the block does not show addresses nothing, so a driver can offer one
key to several excerpts of the same file. Lines carry no names: a driver that
wants readable ones keeps its own table from name to number.
The layer gains `x-numbering`, naming the attribute that numbers a data body,
so `version check` stays free of tag names: it holds the numbering to one
ascending number per body line and refuses a line reference to a number the
body does not quote. The feature gallery's code specimen is now an excerpt.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts: # skills/leaf/assets/runtime/anchor-travel.js # skills/leaf/assets/runtime/indication.js # skills/leaf/packages/default/widgets/lf-code.js # skills/leaf/references/packages.md # tests/runtime/indication.test.mjs # tests/test_render_widgets.py
examples/rust-sort.html plays the merge sort Rust shipped in 1.15 on four inputs, beside the three functions it runs quoted as lf-code excerpts under slice.rs's own line numbers. Each step lights the line it executes through indicate(): the film keeps its step names in a table from name to line numbers and offers each key to all three excerpts, and only the one that quotes the line marks it. The catalog lists it under specialized examples and the corpus carries it as "Sort film". Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Source lines count from 1, so the lines pattern now requires each number to start with a nonzero digit; a line 0 used to render a 0 in the gutter. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
reviewed
Sep 24, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
version check can exhaust memory on an invalid lines value, as noted inline. The current lint check is also red: the new Rust example has trailing whitespace, and the new tests need Ruff fixes before this is ready to merge.
Trailing spaces on blank lines of the Rust sort excerpts, and ruff's formatting of two new tests. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
version check expanded lines into every number it holds, so lines="1-1000000000" on a one-line block tried to allocate a billion entries. It now sums the ranges' lengths and tests a reference against the ranges themselves. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Sep 24, 2026
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 #15.
lf-codecan now quote an excerpt of a longer file under that file's own line numbers. The newlinesattribute uses the range grammarhialready uses (lines="1505-1507,1520-1527"):hi, a note'sat, and another widget's indication key all name lines by those numbers. A range may span a gap.lines, the body is lines 1..N, so quick snippets are unchanged.--lf-code-gutteris a registered<length>, so a note beside the code stays aligned with it.Validation. A new registry key,
x-numbering, names the attribute that numbers a data body.version checkrefuses:x-linesreference to a line the excerpt does not show.Named lines, not added. A line is addressed only by its number. A driver that wants readable names keeps a name→number table in its own code. The worked example does this.
New example.
examples/rust-sort.htmlexplains Rust's 2016 merge sort. The sort film plays beside threelf-codeexcerpts ofslice.rs. Each step callsindicate()with the source line it runs, and the matching excerpt lights that line. The example is in the catalog, and the preview stills are refreshed.feature-gallery.htmlnow useslinestoo.🤖 Generated with Claude Code