MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestTypingIntoChipInteriorKeepsContent

Function TestTypingIntoChipInteriorKeepsContent

internal/tui/prompt_test.go:518–537  ·  view source on GitHub ↗

TestTypingIntoChipInteriorKeepsContent: typing a rune while the cursor sits inside a chip label, when two chips share an identical label, must not split the label and cross-map the survivor to the wrong paste. Update snaps out of the chip before delegating the rune to the textarea.

(t *testing.T)

Source from the content-addressed store, hash-verified

516// the label and cross-map the survivor to the wrong paste. Update snaps out of
517// the chip before delegating the rune to the textarea.
518func TestTypingIntoChipInteriorKeepsContent(t *testing.T) {
519 p := newChippablePrompt()
520 n := pasteChipMinLines + 4
521 a := strings.Repeat("AAAA\n", n-1) + "Aend" // n lines
522 b := strings.Repeat("BBBB\n", n-1) + "Bend" // n lines -> identical label
523 p, _ = p.Update(pasteKey(a))
524 p, _ = p.Update(pasteKey(b))
525 if len(p.spans) != 2 {
526 t.Fatalf("setup: expected 2 chips, got %d", len(p.spans))
527 }
528 p.setCursorRuneOffset(p.spans[0].start + 3) // strictly inside the first label
529 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("Z")})
530 v := p.Value()
531 if !strings.Contains(v, "Aend") {
532 t.Fatalf("paste A content lost/cross-mapped: %q", v)
533 }
534 if !strings.Contains(v, "Bend") {
535 t.Fatalf("paste B content lost/cross-mapped: %q", v)
536 }
537}

Callers

nothing calls this directly

Calls 5

newChippablePromptFunction · 0.85
pasteKeyFunction · 0.85
setCursorRuneOffsetMethod · 0.80
ValueMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected