TestTwoChipsTrackedIndependently: two pastes make two chips; deleting the first leaves the second intact with its span shifted left.
(t *testing.T)
| 172 | // TestTwoChipsTrackedIndependently: two pastes make two chips; deleting the |
| 173 | // first leaves the second intact with its span shifted left. |
| 174 | func TestTwoChipsTrackedIndependently(t *testing.T) { |
| 175 | p := newChippablePrompt() |
| 176 | p, _ = p.Update(pasteKey(makePaste(8))) |
| 177 | p, _ = p.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune(" mid ")}) |
| 178 | p, _ = p.Update(pasteKey(makePaste(15))) |
| 179 | |
| 180 | if len(p.spans) != 2 { |
| 181 | t.Fatalf("expected 2 chips, got %d", len(p.spans)) |
| 182 | } |
| 183 | if p.spans[0].start >= p.spans[1].start { |
| 184 | t.Fatal("chip spans must be sorted left-to-right") |
| 185 | } |
| 186 | |
| 187 | // Delete the first chip. |
| 188 | p.setCursorRuneOffset(p.spans[0].end) |
| 189 | p, _ = p.Update(tea.KeyMsg{Type: tea.KeyBackspace}) |
| 190 | |
| 191 | if len(p.spans) != 1 { |
| 192 | t.Fatalf("after deleting first chip, one should remain; got %d", len(p.spans)) |
| 193 | } |
| 194 | // The remaining chip is the one with 15 lines. |
| 195 | content, ok := p.store[p.spans[0].id] |
| 196 | if !ok { |
| 197 | t.Fatal("remaining span has no store entry") |
| 198 | } |
| 199 | if content.lines != 15 { |
| 200 | t.Fatalf("remaining chip should be the 15-line one, got %d", content.lines) |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | // TestDamagedLabelAmongIdenticalChipsDropsWholeGroup: two pastes with the same |
| 205 | // line count render identical labels. A word-delete at the boundary (Ctrl+W, |
nothing calls this directly
no test coverage detected