MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestBackspaceImmediatelyAfterChipRemovesIt

Function TestBackspaceImmediatelyAfterChipRemovesIt

internal/tui/prompt_test.go:473–485  ·  view source on GitHub ↗

TestBackspaceImmediatelyAfterChipRemovesIt: atomic-delete regression guard, after a paste the cursor sits at chip.end, so one Backspace deletes the chip without any manual cursor setup.

(t *testing.T)

Source from the content-addressed store, hash-verified

471// after a paste the cursor sits at chip.end, so one Backspace deletes the chip
472// without any manual cursor setup.
473func TestBackspaceImmediatelyAfterChipRemovesIt(t *testing.T) {
474 p := newChippablePrompt()
475 p, _ = p.Update(pasteKey(makePaste(10)))
476 // InsertString leaves the cursor at chip.end, tripping the atomic path.
477 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyBackspace})
478
479 if len(p.spans) != 0 {
480 t.Fatalf("single Backspace right after paste should remove chip, spans=%+v", p.spans)
481 }
482 if p.DisplayValue() != "" {
483 t.Fatalf("prompt should be empty after chip delete, got %q", p.DisplayValue())
484 }
485}
486
487// TestPasteIntoChipInteriorKeepsBothPastes: a paste while the cursor sits inside
488// an existing chip's label must not splice the new label into the old one.

Callers

nothing calls this directly

Calls 5

newChippablePromptFunction · 0.85
pasteKeyFunction · 0.85
makePasteFunction · 0.85
DisplayValueMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected