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

Function TestBackspaceNotAtChipBoundaryFallsThrough

internal/tui/prompt_test.go:353–368  ·  view source on GitHub ↗

TestBackspaceNotAtChipBoundaryFallsThrough: Backspace away from a chip boundary deletes one char normally, chip untouched.

(t *testing.T)

Source from the content-addressed store, hash-verified

351// TestBackspaceNotAtChipBoundaryFallsThrough: Backspace away from a chip boundary
352// deletes one char normally, chip untouched.
353func TestBackspaceNotAtChipBoundaryFallsThrough(t *testing.T) {
354 p := newChippablePrompt()
355 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("hello")})
356 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune(" ")})
357 p, _ = p.Update(pasteKey(makePaste(9)))
358 // Cursor ends past the chip; backspace must remove "X", not the chip.
359 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("X")})
360
361 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyBackspace})
362 if len(p.spans) != 1 {
363 t.Fatal("Backspace after non-chip character must not remove the chip")
364 }
365 if strings.HasSuffix(p.DisplayValue(), "X") {
366 t.Fatal("Backspace should have removed the trailing 'X'")
367 }
368}
369
370// TestPageKeysMoveCursorByHeight: PgUp/PgDn move the cursor by one prompt-height.
371// bubbles/textarea ships an empty viewport keymap, so without our handling

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