Implement Anchor, AnchorRangeMap, SelectionSet in multi_buffer
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
co-authored by
Nathan Sobo
parent
a7634ccd5f
commit
daedf179b2
@@ -1,6 +1,5 @@
|
||||
use super::{FromAnchor, FullOffset, Point, ToOffset};
|
||||
use crate::{rope::TextDimension, BufferSnapshot};
|
||||
|
||||
use super::{Buffer, FromAnchor, FullOffset, Point, ToOffset};
|
||||
use anyhow::Result;
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
@@ -99,7 +98,7 @@ impl Anchor {
|
||||
Ok(offset_comparison.then_with(|| self.bias.cmp(&other.bias)))
|
||||
}
|
||||
|
||||
pub fn bias_left(&self, buffer: &Buffer) -> Anchor {
|
||||
pub fn bias_left(&self, buffer: &BufferSnapshot) -> Anchor {
|
||||
if self.bias == Bias::Left {
|
||||
self.clone()
|
||||
} else {
|
||||
@@ -107,7 +106,7 @@ impl Anchor {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bias_right(&self, buffer: &Buffer) -> Anchor {
|
||||
pub fn bias_right(&self, buffer: &BufferSnapshot) -> Anchor {
|
||||
if self.bias == Bias::Right {
|
||||
self.clone()
|
||||
} else {
|
||||
|
||||
@@ -685,6 +685,15 @@ impl sum_tree::Summary for TextSummary {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> std::ops::Add<Self> for TextSummary {
|
||||
type Output = Self;
|
||||
|
||||
fn add(mut self, rhs: Self) -> Self::Output {
|
||||
self.add_assign(&rhs);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> std::ops::AddAssign<&'a Self> for TextSummary {
|
||||
fn add_assign(&mut self, other: &'a Self) {
|
||||
let joined_chars = self.last_line_chars + other.first_line_chars;
|
||||
|
||||
Reference in New Issue
Block a user