Make rename highlights work across multibuffer excerpts

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Keith Simmons 2022-03-24 10:22:47 -07:00
parent ff4bdb3114
commit f6805eb802
9 changed files with 110 additions and 45 deletions

View file

@ -12,7 +12,7 @@ pub struct Anchor {
}
impl Anchor {
pub fn min() -> Self {
pub fn build_min() -> Self {
Self {
timestamp: clock::Local::MIN,
offset: usize::MIN,
@ -20,7 +20,7 @@ impl Anchor {
}
}
pub fn max() -> Self {
pub fn build_max() -> Self {
Self {
timestamp: clock::Local::MAX,
offset: usize::MAX,
@ -42,6 +42,22 @@ impl Anchor {
.then_with(|| self.bias.cmp(&other.bias)))
}
pub fn min(&self, other: &Self, buffer: &BufferSnapshot) -> Self {
if self.cmp(other, buffer).unwrap().is_le() {
self.clone()
} else {
other.clone()
}
}
pub fn max(&self, other: &Self, buffer: &BufferSnapshot) -> Self {
if self.cmp(other, buffer).unwrap().is_ge() {
self.clone()
} else {
other.clone()
}
}
pub fn bias(&self, bias: Bias, buffer: &BufferSnapshot) -> Anchor {
if bias == Bias::Left {
self.bias_left(buffer)