State the step-down rule at drawSteps' climbed, and name the parts of route's draw condition

This commit is contained in:
2026-10-07 01:08:13 +02:00
committed by Lillem4n
parent ac44a2f89b
commit f272c5b025
2 changed files with 9 additions and 6 deletions
+3 -2
View File
@@ -183,9 +183,10 @@ func probePath(n node, tail []string, steps []pathStep) ([]pathStep, error) {
// drawSteps draws the rows and variants a path's steps read from n, pinning the rows in pins; // drawSteps draws the rows and variants a path's steps read from n, pinning the rows in pins;
// pins is nil for a sibling path, which never crosses a table, since a table is only a category. // pins is nil for a sibling path, which never crosses a table, since a table is only a category.
// For a read through a name, memo keeps the variant drawn at each of levels, so paths sharing a // For a read through a name, memo keeps the variant drawn at each of levels, so paths sharing a
// prefix share it. It returns the leaf and the pins its row is in: a step down after a step up draws // prefix share it. It returns the leaf and the pins its row is in.
// afresh, into pins of its own, which memo shares with every path stepping down there.
func drawSteps(s *drawstate.State, n node, steps []pathStep, pins *pinSet, memo *drawMemo, levels []pickKey) (node, *pinSet) { func drawSteps(s *drawstate.State, n node, steps []pathStep, pins *pinSet, memo *drawMemo, levels []pickKey) (node, *pinSet) {
// climbed is the table a ".." stepped up to. The next step down from it draws its row afresh,
// into pins of its own, which memo shares with every path of the pick stepping down there.
var climbed *rowsTable var climbed *rowsTable
for _, st := range steps { for _, st := range steps {
if c, ok := n.(*choice); ok { if c, ok := n.(*choice); ok {
+6 -4
View File
@@ -266,11 +266,13 @@ func (t *table) route(tail []string, descended bool) (tableRoute, error) {
if err != nil { if err != nil {
return tableRoute{}, err return tableRoute{}, err
} }
// A selector further down pins this table by ancestry, so the walk draws only selected, readsRow := sel != "", descended || len(tail) > 0
// where none follows; drawing first could draw a row the selector is not inside. // A selector further down pins this table by ancestry; drawing first could draw a row the
r := tableRoute{sel: sel, draw: sel == "" && (descended || len(tail) > 0) && !grammar.HasSelector(tail)} // selector is not inside.
pinnedBelow := grammar.HasSelector(tail)
r := tableRoute{sel: sel, draw: !selected && readsRow && !pinnedBelow}
switch { switch {
case len(tail) == 0 && sel == "" && !descended: case !selected && !readsRow:
r.next = t r.next = t
case len(tail) == 0: case len(tail) == 0:
r.next = t.rowNode r.next = t.rowNode