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)
| 286 | // and store. Cursor lands at the vacated start; reconcile re-validates later |
| 287 | // spans, which shift left by the removed label length. |
| 288 | func (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. |
no test coverage detected