Finished refactoring out fs and rope
This commit is contained in:
@@ -7,6 +7,7 @@ use collections::{Bound, HashMap, HashSet};
|
||||
use gpui::{ElementBox, RenderContext};
|
||||
use language::{BufferSnapshot, Chunk, Patch};
|
||||
use parking_lot::Mutex;
|
||||
use rope::point::Point;
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
cmp::{self, Ordering},
|
||||
@@ -18,7 +19,7 @@ use std::{
|
||||
},
|
||||
};
|
||||
use sum_tree::{Bias, SumTree};
|
||||
use text::{Edit, Point};
|
||||
use text::Edit;
|
||||
|
||||
const NEWLINES: &[u8] = &[b'\n'; u8::MAX as usize];
|
||||
|
||||
@@ -42,7 +43,7 @@ pub struct BlockSnapshot {
|
||||
pub struct BlockId(usize);
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||
pub struct BlockPoint(pub super::Point);
|
||||
pub struct BlockPoint(pub Point);
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||
struct BlockRow(u32);
|
||||
@@ -994,7 +995,7 @@ mod tests {
|
||||
use rand::prelude::*;
|
||||
use settings::Settings;
|
||||
use std::env;
|
||||
use text::RandomCharIter;
|
||||
use util::RandomCharIter;
|
||||
|
||||
#[gpui::test]
|
||||
fn test_offset_for_row() {
|
||||
|
||||
@@ -5,8 +5,9 @@ use crate::{
|
||||
};
|
||||
use collections::BTreeMap;
|
||||
use gpui::fonts::HighlightStyle;
|
||||
use language::{Chunk, Edit, Point, TextSummary};
|
||||
use language::{Chunk, Edit, TextSummary};
|
||||
use parking_lot::Mutex;
|
||||
use rope::point::Point;
|
||||
use std::{
|
||||
any::TypeId,
|
||||
cmp::{self, Ordering},
|
||||
@@ -18,11 +19,11 @@ use std::{
|
||||
use sum_tree::{Bias, Cursor, FilterCursor, SumTree};
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||
pub struct FoldPoint(pub super::Point);
|
||||
pub struct FoldPoint(pub Point);
|
||||
|
||||
impl FoldPoint {
|
||||
pub fn new(row: u32, column: u32) -> Self {
|
||||
Self(super::Point::new(row, column))
|
||||
Self(Point::new(row, column))
|
||||
}
|
||||
|
||||
pub fn row(self) -> u32 {
|
||||
@@ -1196,8 +1197,8 @@ mod tests {
|
||||
use settings::Settings;
|
||||
use std::{cmp::Reverse, env, mem, sync::Arc};
|
||||
use sum_tree::TreeMap;
|
||||
use text::RandomCharIter;
|
||||
use util::test::sample_text;
|
||||
use util::RandomCharIter;
|
||||
use Bias::{Left, Right};
|
||||
|
||||
#[gpui::test]
|
||||
|
||||
@@ -3,11 +3,12 @@ use super::{
|
||||
TextHighlights,
|
||||
};
|
||||
use crate::MultiBufferSnapshot;
|
||||
use language::{rope, Chunk};
|
||||
use language::Chunk;
|
||||
use parking_lot::Mutex;
|
||||
use rope;
|
||||
use rope::point::Point;
|
||||
use std::{cmp, mem, num::NonZeroU32, ops::Range};
|
||||
use sum_tree::Bias;
|
||||
use text::Point;
|
||||
|
||||
pub struct TabMap(Mutex<TabSnapshot>);
|
||||
|
||||
@@ -332,11 +333,11 @@ impl TabSnapshot {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||
pub struct TabPoint(pub super::Point);
|
||||
pub struct TabPoint(pub Point);
|
||||
|
||||
impl TabPoint {
|
||||
pub fn new(row: u32, column: u32) -> Self {
|
||||
Self(super::Point::new(row, column))
|
||||
Self(Point::new(row, column))
|
||||
}
|
||||
|
||||
pub fn zero() -> Self {
|
||||
@@ -352,8 +353,8 @@ impl TabPoint {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<super::Point> for TabPoint {
|
||||
fn from(point: super::Point) -> Self {
|
||||
impl From<Point> for TabPoint {
|
||||
fn from(point: Point) -> Self {
|
||||
Self(point)
|
||||
}
|
||||
}
|
||||
@@ -362,7 +363,7 @@ pub type TabEdit = text::Edit<TabPoint>;
|
||||
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq)]
|
||||
pub struct TextSummary {
|
||||
pub lines: super::Point,
|
||||
pub lines: Point,
|
||||
pub first_line_chars: u32,
|
||||
pub last_line_chars: u32,
|
||||
pub longest_row: u32,
|
||||
@@ -485,7 +486,6 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::{display_map::fold_map::FoldMap, MultiBuffer};
|
||||
use rand::{prelude::StdRng, Rng};
|
||||
use text::{RandomCharIter, Rope};
|
||||
|
||||
#[test]
|
||||
fn test_expand_tabs() {
|
||||
@@ -508,7 +508,9 @@ mod tests {
|
||||
let tab_size = NonZeroU32::new(rng.gen_range(1..=4)).unwrap();
|
||||
let len = rng.gen_range(0..30);
|
||||
let buffer = if rng.gen() {
|
||||
let text = RandomCharIter::new(&mut rng).take(len).collect::<String>();
|
||||
let text = util::RandomCharIter::new(&mut rng)
|
||||
.take(len)
|
||||
.collect::<String>();
|
||||
MultiBuffer::build_simple(&text, cx)
|
||||
} else {
|
||||
MultiBuffer::build_random(&mut rng, cx)
|
||||
@@ -522,7 +524,7 @@ mod tests {
|
||||
log::info!("FoldMap text: {:?}", folds_snapshot.text());
|
||||
|
||||
let (_, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), tab_size);
|
||||
let text = Rope::from(tabs_snapshot.text().as_str());
|
||||
let text = rope::Rope::from(tabs_snapshot.text().as_str());
|
||||
log::info!(
|
||||
"TabMap text (tab size: {}): {:?}",
|
||||
tab_size,
|
||||
|
||||
@@ -3,13 +3,14 @@ use super::{
|
||||
tab_map::{self, TabEdit, TabPoint, TabSnapshot},
|
||||
TextHighlights,
|
||||
};
|
||||
use crate::{MultiBufferSnapshot, Point};
|
||||
use crate::MultiBufferSnapshot;
|
||||
use gpui::{
|
||||
fonts::FontId, text_layout::LineWrapper, Entity, ModelContext, ModelHandle, MutableAppContext,
|
||||
Task,
|
||||
};
|
||||
use language::Chunk;
|
||||
use lazy_static::lazy_static;
|
||||
use rope::point::Point;
|
||||
use smol::future::yield_now;
|
||||
use std::{cmp, collections::VecDeque, mem, ops::Range, time::Duration};
|
||||
use sum_tree::{Bias, Cursor, SumTree};
|
||||
@@ -52,7 +53,7 @@ struct TransformSummary {
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||
pub struct WrapPoint(pub super::Point);
|
||||
pub struct WrapPoint(pub Point);
|
||||
|
||||
pub struct WrapChunks<'a> {
|
||||
input_chunks: tab_map::TabChunks<'a>,
|
||||
@@ -959,7 +960,7 @@ impl SumTreeExt for SumTree<Transform> {
|
||||
|
||||
impl WrapPoint {
|
||||
pub fn new(row: u32, column: u32) -> Self {
|
||||
Self(super::Point::new(row, column))
|
||||
Self(Point::new(row, column))
|
||||
}
|
||||
|
||||
pub fn row(self) -> u32 {
|
||||
@@ -1029,7 +1030,6 @@ mod tests {
|
||||
MultiBuffer,
|
||||
};
|
||||
use gpui::test::observe;
|
||||
use language::RandomCharIter;
|
||||
use rand::prelude::*;
|
||||
use settings::Settings;
|
||||
use smol::stream::StreamExt;
|
||||
@@ -1067,7 +1067,9 @@ mod tests {
|
||||
MultiBuffer::build_random(&mut rng, cx)
|
||||
} else {
|
||||
let len = rng.gen_range(0..10);
|
||||
let text = RandomCharIter::new(&mut rng).take(len).collect::<String>();
|
||||
let text = util::RandomCharIter::new(&mut rng)
|
||||
.take(len)
|
||||
.collect::<String>();
|
||||
MultiBuffer::build_simple(&text, cx)
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user