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

Function TestBackspaceAtChipEndRemovesWholeChip

internal/tui/prompt_test.go:93–110  ·  view source on GitHub ↗

TestBackspaceAtChipEndRemovesWholeChip: Backspace with the cursor right after the label deletes the whole chip and leaves surrounding text intact.

(t *testing.T)

Source from the content-addressed store, hash-verified

91// TestBackspaceAtChipEndRemovesWholeChip: Backspace with the cursor right after
92// the label deletes the whole chip and leaves surrounding text intact.
93func TestBackspaceAtChipEndRemovesWholeChip(t *testing.T) {
94 p := newChippablePrompt()
95 // Prefix, big paste, suffix.
96 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("before ")})
97 p, _ = p.Update(pasteKey(makePaste(10)))
98 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune(" after")})
99
100 // Cursor to the chip's trailing edge.
101 p.setCursorRuneOffset(p.spans[0].end)
102
103 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyBackspace})
104 if len(p.spans) != 0 {
105 t.Fatalf("Backspace at chip.end must remove the chip; spans=%+v", p.spans)
106 }
107 if got := p.DisplayValue(); got != "before after" {
108 t.Fatalf("after delete value = %q, want 'before after'", got)
109 }
110}
111
112// TestDeleteAtChipStartRemovesWholeChip: forward-Delete with the cursor right
113// before the label removes the whole chip.

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected