mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-21 16:10:19 +01:00
9b9f25ff39
Long story short: 1. Whenever we pick a buffer for mutation in https://github.com/zed-industries/zed/blob/b8c5f672cdf8ed3c1f4c8016f2b8d6d84b7a7a9c/crates/multi_buffer/src/multi_buffer.rs#L3831, we seed from a hashmap<BufferId, _>. 2. That HashMap is not RNG-seeded by itself (good), but the BufferIds are: they are derived from entity ID in https://github.com/zed-industries/zed/blob/b8c5f672cdf8ed3c1f4c8016f2b8d6d84b7a7a9c/crates/project/src/buffer_store.rs#L641 3.^ was introduced in https://github.com/zed-industries/zed/pull/10347 4.The HashMap is not randomized, but the order of it's values could shift when the keys (buffer ids) change. 5. Thus, we'll end up mutating a different buffer in the multi-buffer when BufferIds shift around. Our "fix" is that we're using a btreemap for buffer storage, which should ensure that the order of iteration (and seeding) the candidates matches up with the order of buffer creation. Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Closes #ISSUE Release Notes: - N/A Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>