Remove language servers from buffers

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
Co-Authored-By: Keith Simmons <keith@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-03-08 19:00:54 +01:00 committed by Max Brunsfeld
parent 6662ba62a3
commit 317a1bb07b
14 changed files with 1584 additions and 1235 deletions

View file

@ -1,5 +1,5 @@
use super::{Point, ToOffset};
use crate::{rope::TextDimension, BufferSnapshot, PointUtf16, ToPointUtf16};
use crate::{rope::TextDimension, BufferSnapshot, PointUtf16, ToPoint, ToPointUtf16};
use anyhow::Result;
use std::{cmp::Ordering, fmt::Debug, ops::Range};
use sum_tree::Bias;
@ -74,11 +74,33 @@ impl Anchor {
}
}
pub trait OffsetRangeExt {
fn to_offset(&self, snapshot: &BufferSnapshot) -> Range<usize>;
fn to_point(&self, snapshot: &BufferSnapshot) -> Range<Point>;
fn to_point_utf16(&self, snapshot: &BufferSnapshot) -> Range<PointUtf16>;
}
impl<T> OffsetRangeExt for Range<T>
where
T: ToOffset,
{
fn to_offset(&self, snapshot: &BufferSnapshot) -> Range<usize> {
self.start.to_offset(snapshot)..self.end.to_offset(&snapshot)
}
fn to_point(&self, snapshot: &BufferSnapshot) -> Range<Point> {
self.start.to_offset(snapshot).to_point(snapshot)
..self.end.to_offset(snapshot).to_point(snapshot)
}
fn to_point_utf16(&self, snapshot: &BufferSnapshot) -> Range<PointUtf16> {
self.start.to_offset(snapshot).to_point_utf16(snapshot)
..self.end.to_offset(snapshot).to_point_utf16(snapshot)
}
}
pub trait AnchorRangeExt {
fn cmp(&self, b: &Range<Anchor>, buffer: &BufferSnapshot) -> Result<Ordering>;
fn to_offset(&self, content: &BufferSnapshot) -> Range<usize>;
fn to_point(&self, content: &BufferSnapshot) -> Range<Point>;
fn to_point_utf16(&self, content: &BufferSnapshot) -> Range<PointUtf16>;
}
impl AnchorRangeExt for Range<Anchor> {
@ -88,16 +110,4 @@ impl AnchorRangeExt for Range<Anchor> {
ord @ _ => ord,
})
}
fn to_offset(&self, content: &BufferSnapshot) -> Range<usize> {
self.start.to_offset(&content)..self.end.to_offset(&content)
}
fn to_point(&self, content: &BufferSnapshot) -> Range<Point> {
self.start.summary::<Point>(&content)..self.end.summary::<Point>(&content)
}
fn to_point_utf16(&self, content: &BufferSnapshot) -> Range<PointUtf16> {
self.start.to_point_utf16(content)..self.end.to_point_utf16(content)
}
}