# Fix panic when collaborating with new multibuffers \(\#29245\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/4a8f114528d3d307f0a6b2f9d82dcc96cf1cd8d1)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 4a8f114528d3d307f0a6b2f9d82dcc96cf1cd8d1

Requested commit: 4a8f114528d3d307f0a6b2f9d82dcc96cf1cd8d1

Commit: 4a8f114528d3d307f0a6b2f9d82dcc96cf1cd8d1

Tree: 248b44cd9da9e85a2987618f00d95dd874b123ec

Author: Conrad Irwin

Committer: GitHub

## Message

```
Fix panic when collaborating with new multibuffers (#29245)

Before this change, when syncing a multibuffer (such as
find-all-references) to a remote, we would renumber the excerpts from 1.
This did not matter in the past because the buffers' list of excerpts
could not change. In #27876, I added the ability for excerpts to merge,
which meant that the excerpt list could change. This manifested as
people seeing "invalid excerpt id" panics when syncing.

The initial fix to this (to re-use the excerpt ids from the host) ran
into problems because `insert_excerpts_with_ids_after` assumes that you
call it in excerpt-id order. This change de-optimizes that code to
insert the excerpts 1-by-1 in excerpt-id order, but with the
insert_after set to preserve the correct UI order.

I hope to soon remove this code path and use something more like
set-excerpts-for-path for syncing, but in the meantime we should not
panic.

Release Notes:

- Fix a panic when joining a project with a multibuffer with merged
excerpts
```

## Parents

- [ce1a674ebad2a4ecc48dea029f73660483c74a64](https://git.cafe/gitcafe/zed/commit/ce1a674ebad2a4ecc48dea029f73660483c74a64?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/4a8f114528d3d307f0a6b2f9d82dcc96cf1cd8d1?format=markdown)
