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)
| 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. |
| 518 | func 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 | } |
nothing calls this directly
no test coverage detected