Skip to content

fix(view): shorten a bead id against the node above it - #77

Merged
GraemeF merged 2 commits into
mainfrom
abbrev
Sep 12, 2026
Merged

fix(view): shorten a bead id against the node above it#77
GraemeF merged 2 commits into
mainfrom
abbrev

Conversation

@GraemeF

@GraemeF GraemeF commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

One row on the screen gets longer, and that is the part worth looking at. A bead drawn under one it blocks rather than under its parent was reading as that bead's child: slu-1.1 hanging off slu-1.2 drew .1. It now draws slu-1.1. Everything else here is ids getting shorter.

The rule is that a bead omits the part of its id the bead on the row above already spells, and draws whole where that bead's id is not the front of its own. Before this, an id was measured against the tree's root, so a branch whose own id was nothing like the root's drew in full and so did every bead beneath it. abbreviate now takes the id above it as an Option, so a row with nothing above it says that in the type rather than by being handed its own id.

That takes the focused-root case with it. A rooted forest shortened every row against the bead it started at, which is this rule written for one depth only. shortened_against is deleted rather than left beside the general rule: the bead a rooted forest starts at is a row with nothing above it, and draws whole for the same reason a tree's root does.

Walking up the rows and joining what each says gives the whole id back. That property is tested in the forest and not in view::row, because abbreviate cannot promise it — handed a grandchild and the tree's root it sees a real string prefix, with no way to know the row above says something else. Choosing the parent is the layout's job, so the layout is where the property lives. It goes red when the layout is pointed back at the tree root.

One existing test now tests what its name promises. a_search_matches_the_shortened_id_the_row_draws spelled its query by hand, as .1.1 — a form no row draws under the new rule, and one that passed anyway because a search matches on the whole id, where any suffix is a substring. The query is now read off the row, so the drawn form and the thing searched for cannot drift apart. With the layout weakened so every row draws its whole id, the hand-spelled query still passes and the one taken off the row does not.

An id was measured against the tree's root, so a branch whose own id was
nothing like the root's drew in full and so did every bead beneath it,
including the ones the branch's id is the front of. A reader met a column of
whole ids on exactly the pairs they could most easily have read as one thing.

The rule is now that a bead omits the part of its id the bead on the row above
already spells, and draws whole where that bead's id is not the front of its
own. It holds at every depth and in every tree, so walking up the rows and
joining what each says gives the whole id back.

That takes the focused-root case with it. A rooted forest shortened every row
against the bead it started at, which is this rule written for one depth only;
the bead a rooted forest starts at is now a row with nothing above it, and
draws whole for the same reason a tree's root does.

A copy drawn under a bead it does not descend from now reads whole where it
used to read as that bead's child. The sluice fixture draws both copies of one
bead, and the second says `slu-1.1` rather than `.1`.
The test promising that a reader can type what the row showed them spelled the
query by hand. A search matches on the whole id, so a hand-spelled suffix
passes on that alone and never touches the drawn form at all.

Taking the query off the row couples the two. With the layout weakened so every
row draws its whole id, the hand-spelled `.1` still passes and this does not.
@GraemeF
GraemeF merged commit 63226c8 into main Sep 12, 2026
2 checks passed
@GraemeF
GraemeF deleted the abbrev branch September 12, 2026 12:42
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.

1 participant