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

Method deleteSpan

internal/tui/prompt.go:288–300  ·  view source on GitHub ↗

deleteSpan removes the chip's label from the value and drops it from spans and store. Cursor lands at the vacated start; reconcile re-validates later spans, which shift left by the removed label length.

(chip chipSpan)

Source from the content-addressed store, hash-verified

286// and store. Cursor lands at the vacated start; reconcile re-validates later
287// spans, which shift left by the removed label length.
288func (p *promptInput) deleteSpan(chip chipSpan) {
289 value := p.ta.Value()
290 runes := []rune(value)
291 if chip.end > len(runes) {
292 return
293 }
294 spliced := string(runes[:chip.start]) + string(runes[chip.end:])
295 p.ta.SetValue(spliced)
296 p.setCursorRuneOffset(chip.start)
297 delete(p.store, chip.id)
298 p.spans = slices.DeleteFunc(p.spans, func(s chipSpan) bool { return s.id == chip.id })
299 p.reconcile()
300}
301
302// reconcile re-finds each chip's label in the value (searching past the prior
303// span's end) and updates offsets. A span whose label has vanished (e.g.

Callers 1

handleChipKeyMethod · 0.95

Calls 4

setCursorRuneOffsetMethod · 0.95
reconcileMethod · 0.95
ValueMethod · 0.80
SetValueMethod · 0.80

Tested by

no test coverage detected