Rename buffer crate to text and name its entrypoint after the crate
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
co-authored by
Max Brunsfeld
parent
eacd2a45bb
commit
d3f28166cb
@@ -2,7 +2,6 @@ use super::{
|
||||
wrap_map::{self, Edit as WrapEdit, Snapshot as WrapSnapshot, WrapPoint},
|
||||
BlockStyle, DisplayRow,
|
||||
};
|
||||
use buffer::{rope, Anchor, Bias, Edit, Point, Rope, ToOffset, ToPoint as _};
|
||||
use gpui::{fonts::HighlightStyle, AppContext, ModelHandle};
|
||||
use language::{Buffer, Chunk};
|
||||
use parking_lot::Mutex;
|
||||
@@ -19,6 +18,7 @@ use std::{
|
||||
vec,
|
||||
};
|
||||
use sum_tree::SumTree;
|
||||
use text::{rope, Anchor, Bias, Edit, Point, Rope, ToOffset, ToPoint as _};
|
||||
use theme::SyntaxTheme;
|
||||
|
||||
pub struct BlockMap {
|
||||
@@ -1003,11 +1003,11 @@ fn offset_for_row(s: &str, target: u32) -> (u32, usize) {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::display_map::{fold_map::FoldMap, tab_map::TabMap, wrap_map::WrapMap};
|
||||
use buffer::RandomCharIter;
|
||||
use gpui::color::Color;
|
||||
use language::Buffer;
|
||||
use rand::prelude::*;
|
||||
use std::env;
|
||||
use text::RandomCharIter;
|
||||
|
||||
#[gpui::test]
|
||||
fn test_offset_for_row() {
|
||||
|
||||
@@ -110,7 +110,7 @@ impl<'a> FoldMapWriter<'a> {
|
||||
if range.start != range.end {
|
||||
let fold = Fold(buffer.anchor_after(range.start)..buffer.anchor_before(range.end));
|
||||
folds.push(fold);
|
||||
edits.push(buffer::Edit {
|
||||
edits.push(text::Edit {
|
||||
old: range.clone(),
|
||||
new: range,
|
||||
});
|
||||
@@ -154,7 +154,7 @@ impl<'a> FoldMapWriter<'a> {
|
||||
let mut folds_cursor = intersecting_folds(&buffer, &self.0.folds, range, true);
|
||||
while let Some(fold) = folds_cursor.item() {
|
||||
let offset_range = fold.0.start.to_offset(&buffer)..fold.0.end.to_offset(&buffer);
|
||||
edits.push(buffer::Edit {
|
||||
edits.push(text::Edit {
|
||||
old: offset_range.clone(),
|
||||
new: offset_range,
|
||||
});
|
||||
@@ -285,11 +285,7 @@ impl FoldMap {
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_edits(
|
||||
&self,
|
||||
buffer_edits: Vec<buffer::Edit<usize>>,
|
||||
cx: &AppContext,
|
||||
) -> Vec<FoldEdit> {
|
||||
fn apply_edits(&self, buffer_edits: Vec<text::Edit<usize>>, cx: &AppContext) -> Vec<FoldEdit> {
|
||||
let buffer = self.buffer.read(cx).snapshot();
|
||||
let mut buffer_edits_iter = buffer_edits.iter().cloned().peekable();
|
||||
|
||||
@@ -713,7 +709,7 @@ impl Snapshot {
|
||||
}
|
||||
|
||||
fn intersecting_folds<'a, T>(
|
||||
buffer: &'a buffer::Snapshot,
|
||||
buffer: &'a text::Snapshot,
|
||||
folds: &'a SumTree<Fold>,
|
||||
range: Range<T>,
|
||||
inclusive: bool,
|
||||
@@ -738,7 +734,7 @@ where
|
||||
)
|
||||
}
|
||||
|
||||
fn consolidate_buffer_edits(edits: &mut Vec<buffer::Edit<usize>>) {
|
||||
fn consolidate_buffer_edits(edits: &mut Vec<text::Edit<usize>>) {
|
||||
edits.sort_unstable_by(|a, b| {
|
||||
a.old
|
||||
.start
|
||||
@@ -864,9 +860,9 @@ impl Default for FoldSummary {
|
||||
}
|
||||
|
||||
impl sum_tree::Summary for FoldSummary {
|
||||
type Context = buffer::Snapshot;
|
||||
type Context = text::Snapshot;
|
||||
|
||||
fn add_summary(&mut self, other: &Self, buffer: &buffer::Snapshot) {
|
||||
fn add_summary(&mut self, other: &Self, buffer: &text::Snapshot) {
|
||||
if other.min_start.cmp(&self.min_start, buffer).unwrap() == Ordering::Less {
|
||||
self.min_start = other.min_start.clone();
|
||||
}
|
||||
@@ -890,20 +886,20 @@ impl sum_tree::Summary for FoldSummary {
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::Dimension<'a, FoldSummary> for Fold {
|
||||
fn add_summary(&mut self, summary: &'a FoldSummary, _: &buffer::Snapshot) {
|
||||
fn add_summary(&mut self, summary: &'a FoldSummary, _: &text::Snapshot) {
|
||||
self.0.start = summary.start.clone();
|
||||
self.0.end = summary.end.clone();
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::SeekTarget<'a, FoldSummary, Fold> for Fold {
|
||||
fn cmp(&self, other: &Self, buffer: &buffer::Snapshot) -> Ordering {
|
||||
fn cmp(&self, other: &Self, buffer: &text::Snapshot) -> Ordering {
|
||||
self.0.cmp(&other.0, buffer).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> sum_tree::Dimension<'a, FoldSummary> for usize {
|
||||
fn add_summary(&mut self, summary: &'a FoldSummary, _: &buffer::Snapshot) {
|
||||
fn add_summary(&mut self, summary: &'a FoldSummary, _: &text::Snapshot) {
|
||||
*self += summary.count;
|
||||
}
|
||||
}
|
||||
@@ -1078,9 +1074,9 @@ impl FoldEdit {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{test::sample_text, ToPoint};
|
||||
use buffer::RandomCharIter;
|
||||
use rand::prelude::*;
|
||||
use std::{env, mem};
|
||||
use text::RandomCharIter;
|
||||
use Bias::{Left, Right};
|
||||
|
||||
#[gpui::test]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::{cmp, mem};
|
||||
|
||||
type Edit = buffer::Edit<u32>;
|
||||
type Edit = text::Edit<u32>;
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Eq)]
|
||||
pub struct Patch(Vec<Edit>);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use super::fold_map::{self, FoldEdit, FoldPoint, Snapshot as FoldSnapshot, ToFoldPoint};
|
||||
use buffer::Point;
|
||||
use language::{rope, Chunk};
|
||||
use parking_lot::Mutex;
|
||||
use std::{cmp, mem, ops::Range};
|
||||
use sum_tree::Bias;
|
||||
use text::Point;
|
||||
use theme::SyntaxTheme;
|
||||
|
||||
pub struct TabMap(Mutex<Snapshot>);
|
||||
@@ -451,9 +451,9 @@ impl<'a> Iterator for Chunks<'a> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::display_map::fold_map::FoldMap;
|
||||
use buffer::{RandomCharIter, Rope};
|
||||
use language::Buffer;
|
||||
use rand::{prelude::StdRng, Rng};
|
||||
use text::{RandomCharIter, Rope};
|
||||
|
||||
#[test]
|
||||
fn test_expand_tabs() {
|
||||
|
||||
@@ -16,7 +16,7 @@ use sum_tree::{Bias, Cursor, SumTree};
|
||||
use theme::SyntaxTheme;
|
||||
|
||||
pub use super::tab_map::TextSummary;
|
||||
pub type Edit = buffer::Edit<u32>;
|
||||
pub type Edit = text::Edit<u32>;
|
||||
|
||||
pub struct WrapMap {
|
||||
snapshot: Snapshot,
|
||||
@@ -991,10 +991,10 @@ mod tests {
|
||||
display_map::{fold_map::FoldMap, tab_map::TabMap},
|
||||
test::Observer,
|
||||
};
|
||||
use buffer::Rope;
|
||||
use language::{Buffer, RandomCharIter};
|
||||
use rand::prelude::*;
|
||||
use std::{cmp, env};
|
||||
use text::Rope;
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
async fn test_random_wraps(mut cx: gpui::TestAppContext, mut rng: StdRng) {
|
||||
|
||||
Reference in New Issue
Block a user