Skip to content

Commit 026959b

Browse files
author
gluck
committed
cli: a delta row wears its block's wash, not one of its own
Selecting a delta broke the band: the adornment row took a segment of its own and the message it explains went dark, which reads as having left the message. The wash is asked block by block now, so the block stays lifted whole and the snake's head is the only thing that moves.
1 parent 4d22017 commit 026959b

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

‎internal/cli/adornment_pty_test.go‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,16 @@ func adornRowsWalk(t *testing.T, p *adornPane) {
214214
if !wash[p.only(t, rows, adornAsk)] {
215215
t.Errorf("^P past the first row did not select the parent block\n%s", p.dump())
216216
}
217+
// THE ADORNMENT IS PART OF THE BLOCK, so the block's wash covers its rows
218+
// whether the cursor is on the block or inside its list. What changes is
219+
// where the head sits, and nothing else.
217220
for _, key := range adornAskKeys {
218-
if i := p.only(t, rows, key); wash[i] {
219-
t.Errorf("the parent's wash reached delta row %q: %q", key, clean(rows[i]))
221+
i := p.only(t, rows, key)
222+
if !wash[i] {
223+
t.Errorf("the block's wash stopped short of its delta row %q: %q", key, clean(rows[i]))
224+
}
225+
if strings.Contains(rows[i], deltaGlyph) {
226+
t.Errorf("the head stayed on delta row %q with the block selected: %q", key, clean(rows[i]))
220227
}
221228
}
222229
}
@@ -305,20 +312,24 @@ func adornBodyAndList(t *testing.T, p *adornPane) {
305312

306313
// adornFocus asserts the cursor stands on the row holding key: washed, with
307314
// the snake's head in its spine column, and alone in both.
315+
// adornFocus: the cursor stands on key's row. THE HEAD SAYS WHICH ROW, THE
316+
// WASH SAYS WHICH BLOCK: a delta row is part of the block it explains, so the
317+
// block stays lifted whole and only the Δ moves (Gluck, 2026-09-16: "the
318+
// background highlight of the parent should be retained").
308319
func adornFocus(t *testing.T, p *adornPane, key, what string) {
309320
t.Helper()
310321
wash, plain := p.paneWashed(), p.rows()
311322
i := p.only(t, plain, key)
312323
if !wash[i] {
313-
t.Errorf("%s: the row for %q is not the focus\n%s", what, key, p.dump())
324+
t.Errorf("%s: the row for %q is not washed with its block\n%s", what, key, p.dump())
314325
return
315326
}
316327
if !strings.Contains(plain[i], deltaGlyph) {
317328
t.Errorf("%s: the row for %q carries no head: %q", what, key, plain[i])
318329
}
319330
for j, row := range plain {
320-
if j != i && wash[j] && strings.Contains(row, "->") {
321-
t.Errorf("%s: row %d is a washed delta row too: %q", what, j, row)
331+
if j != i && strings.Contains(row, "->") && strings.Contains(row, deltaGlyph) {
332+
t.Errorf("%s: row %d carries a second head: %q", what, j, row)
322333
}
323334
}
324335
}

‎internal/cli/transcript_index.go‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,15 +488,22 @@ func (t *transcript) selectionSpan() selectionSpan {
488488
return selectionSpan{active: true, lo: lo, hi: hi, focus: t.selection.focus.nodeRef}
489489
}
490490

491+
// THE WASH IS THE BLOCK'S, NEVER A DELTA ROW'S OWN. An adornment row is part
492+
// of the block it explains, so selecting one lifts that whole block and the
493+
// snake's head (the Δ) says which row the cursor stands on. A band that broke
494+
// to highlight one adornment row told the reader they had left the message,
495+
// which they had not.
491496
func (s selectionSpan) mark(ref nodeRef) selectionMark {
492497
if !s.active {
493498
return selectionMark{}
494499
}
495-
p := selectionPoint{nodeRef: ref}
496-
if pointLess(p, s.lo) || pointLess(s.hi, p) {
500+
block := blockOf(ref)
501+
p := selectionPoint{nodeRef: block}
502+
if pointLess(p, selectionPoint{nodeRef: blockOf(s.lo.nodeRef)}) ||
503+
pointLess(selectionPoint{nodeRef: blockOf(s.hi.nodeRef)}, p) {
497504
return selectionMark{}
498505
}
499-
return selectionMark{selected: true, active: ref == s.focus}
506+
return selectionMark{selected: true, active: block == blockOf(s.focus)}
500507
}
501508

502509
// nodeSpanOf reports the line range a node occupies, derived from the index

0 commit comments

Comments
 (0)