Ensure selections stay sorted after refreshing them

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-01-11 17:16:45 +01:00
parent e70b728758
commit aa543a4b0a
2 changed files with 42 additions and 25 deletions

View file

@ -2688,6 +2688,15 @@ mod tests {
anchors.push(multibuffer.anchor_at(offset, bias));
anchors.sort_by(|a, b| a.cmp(&b, &multibuffer).unwrap());
}
40..=44 if !anchors.is_empty() => {
let multibuffer = multibuffer.read(cx).read(cx);
anchors = multibuffer
.refresh_anchors(&anchors)
.into_iter()
.map(|a| a.0)
.collect();
anchors.sort_by(|a, b| a.cmp(&b, &multibuffer).unwrap());
}
_ => {
let buffer_handle = if buffers.is_empty() || rng.gen_bool(0.4) {
let base_text = RandomCharIter::new(&mut rng).take(10).collect::<String>();