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

Function TestTypingShiftsSpans

internal/tui/prompt_test.go:274–292  ·  view source on GitHub ↗

TestTypingShiftsSpans: typing before a chip shifts its span right by one; reconcile tracks it automatically.

(t *testing.T)

Source from the content-addressed store, hash-verified

272// TestTypingShiftsSpans: typing before a chip shifts its span right by one;
273// reconcile tracks it automatically.
274func TestTypingShiftsSpans(t *testing.T) {
275 p := newChippablePrompt()
276 p, _ = p.Update(pasteKey(makePaste(10)))
277 origStart := p.spans[0].start
278 if origStart != 0 {
279 t.Fatalf("precondition: chip starts at 0, got %d", origStart)
280 }
281
282 // Move cursor home, type a character.
283 p.setCursorRuneOffset(0)
284 p, _ = p.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("x")})
285
286 if len(p.spans) != 1 {
287 t.Fatalf("typing before chip must not destroy it, spans=%+v", p.spans)
288 }
289 if p.spans[0].start != 1 {
290 t.Fatalf("chip start should shift to 1, got %d", p.spans[0].start)
291 }
292}
293
294// TestEntryRestoreRoundTrip: Entry()+Restore() fully recovers chip state:
295// display text, spans, expanded Value(). Backs ↑/↓ history replay.

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected