Use &Snapshot directly instead of impl Into<Content<'a>>
The text::Buffer and its snapshot already used the same representation for their content, so we can just make Buffer deref to a Snapshot.
This commit is contained in:
@@ -359,7 +359,8 @@ impl FoldMap {
|
||||
}
|
||||
|
||||
if fold.start > sum.input.bytes {
|
||||
let text_summary = buffer.text_summary_for_range(sum.input.bytes..fold.start);
|
||||
let text_summary = buffer
|
||||
.text_summary_for_range::<TextSummary, _>(sum.input.bytes..fold.start);
|
||||
new_transforms.push(
|
||||
Transform {
|
||||
summary: TransformSummary {
|
||||
@@ -400,7 +401,8 @@ impl FoldMap {
|
||||
|
||||
let sum = new_transforms.summary();
|
||||
if sum.input.bytes < edit.new.end {
|
||||
let text_summary = buffer.text_summary_for_range(sum.input.bytes..edit.new.end);
|
||||
let text_summary =
|
||||
buffer.text_summary_for_range::<TextSummary, _>(sum.input.bytes..edit.new.end);
|
||||
new_transforms.push(
|
||||
Transform {
|
||||
summary: TransformSummary {
|
||||
@@ -539,7 +541,7 @@ impl Snapshot {
|
||||
let buffer_end = cursor.start().1 + end_in_transform;
|
||||
summary += self
|
||||
.buffer_snapshot
|
||||
.text_summary_for_range(buffer_start..buffer_end);
|
||||
.text_summary_for_range::<TextSummary, _>(buffer_start..buffer_end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1358,7 +1358,7 @@ impl Editor {
|
||||
let buffer = self.buffer.read(cx);
|
||||
if old_selections
|
||||
.iter()
|
||||
.zip(autoclose_pair_state.ranges.ranges::<usize, _>(buffer))
|
||||
.zip(autoclose_pair_state.ranges.ranges::<usize>(buffer))
|
||||
.all(|(selection, autoclose_range)| {
|
||||
let autoclose_range_end = autoclose_range.end.to_offset(buffer);
|
||||
selection.is_empty() && selection.start == autoclose_range_end
|
||||
@@ -3072,7 +3072,7 @@ impl Editor {
|
||||
.read(cx)
|
||||
.selection_set(set_id)
|
||||
.unwrap()
|
||||
.intersecting_selections::<Point, _, _>(range, buffer);
|
||||
.intersecting_selections::<Point, _>(range, buffer);
|
||||
|
||||
selections
|
||||
.map(move |s| Selection {
|
||||
@@ -3090,7 +3090,7 @@ impl Editor {
|
||||
D: 'a + TextDimension<'a> + Ord,
|
||||
{
|
||||
let buffer = self.buffer.read(cx);
|
||||
let mut selections = self.selection_set(cx).selections::<D, _>(buffer).peekable();
|
||||
let mut selections = self.selection_set(cx).selections::<D>(buffer).peekable();
|
||||
let mut pending_selection = self.pending_selection(cx);
|
||||
iter::from_fn(move || {
|
||||
if let Some(pending) = pending_selection.as_mut() {
|
||||
@@ -3124,8 +3124,8 @@ impl Editor {
|
||||
let buffer = self.buffer.read(cx);
|
||||
self.pending_selection.as_ref().map(|pending| Selection {
|
||||
id: pending.selection.id,
|
||||
start: pending.selection.start.summary::<D, _>(buffer),
|
||||
end: pending.selection.end.summary::<D, _>(buffer),
|
||||
start: pending.selection.start.summary::<D>(buffer),
|
||||
end: pending.selection.end.summary::<D>(buffer),
|
||||
reversed: pending.selection.reversed,
|
||||
goal: pending.selection.goal,
|
||||
})
|
||||
@@ -3201,7 +3201,7 @@ impl Editor {
|
||||
if selections.len() == autoclose_pair_state.ranges.len() {
|
||||
selections
|
||||
.iter()
|
||||
.zip(autoclose_pair_state.ranges.ranges::<Point, _>(buffer))
|
||||
.zip(autoclose_pair_state.ranges.ranges::<Point>(buffer))
|
||||
.all(|(selection, autoclose_range)| {
|
||||
let head = selection.head().to_point(&*buffer);
|
||||
autoclose_range.start <= head && autoclose_range.end >= head
|
||||
|
||||
@@ -183,7 +183,7 @@ pub fn next_word_boundary(map: &DisplayMapSnapshot, mut point: DisplayPoint) ->
|
||||
|
||||
pub fn is_inside_word(map: &DisplayMapSnapshot, point: DisplayPoint) -> bool {
|
||||
let ix = map.clip_point(point, Bias::Left).to_offset(map, Bias::Left);
|
||||
let text = map.buffer_snapshot.text();
|
||||
let text = &map.buffer_snapshot;
|
||||
let next_char_kind = text.chars_at(ix).next().map(char_kind);
|
||||
let prev_char_kind = text.reversed_chars_at(ix).next().map(char_kind);
|
||||
prev_char_kind.zip(next_char_kind) == Some((CharKind::Word, CharKind::Word))
|
||||
@@ -193,7 +193,7 @@ pub fn surrounding_word(map: &DisplayMapSnapshot, point: DisplayPoint) -> Range<
|
||||
let mut start = map.clip_point(point, Bias::Left).to_offset(map, Bias::Left);
|
||||
let mut end = start;
|
||||
|
||||
let text = map.buffer_snapshot.text();
|
||||
let text = &map.buffer_snapshot;
|
||||
let mut next_chars = text.chars_at(start).peekable();
|
||||
let mut prev_chars = text.reversed_chars_at(start).peekable();
|
||||
let word_kind = cmp::max(
|
||||
|
||||
Reference in New Issue
Block a user