From f8c262016629b0a66bb97c442857326c187ea2fd Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 5 Jan 2022 15:04:50 +0100 Subject: [PATCH] Fix `Buffer::remote_selections_in_range` at query range boundaries --- crates/language/src/buffer.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index a993feacf5..19325d4341 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -1814,14 +1814,22 @@ impl BufferSnapshot { .iter() .filter(|(replica_id, _)| **replica_id != self.text.replica_id()) .map(move |(replica_id, selections)| { - let start_ix = match selections - .binary_search_by(|probe| probe.end.cmp(&range.start, self).unwrap()) - { + let start_ix = match selections.binary_search_by(|probe| { + probe + .end + .cmp(&range.start, self) + .unwrap() + .then(Ordering::Greater) + }) { Ok(ix) | Err(ix) => ix, }; - let end_ix = match selections - .binary_search_by(|probe| probe.start.cmp(&range.end, self).unwrap()) - { + let end_ix = match selections.binary_search_by(|probe| { + probe + .start + .cmp(&range.end, self) + .unwrap() + .then(Ordering::Less) + }) { Ok(ix) | Err(ix) => ix, };