mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 10:29:35 +03:00
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:
parent
eacd2a45bb
commit
d3f28166cb
40
Cargo.lock
generated
40
Cargo.lock
generated
@ -739,21 +739,6 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "buffer"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"arrayvec 0.7.1",
|
|
||||||
"clock",
|
|
||||||
"collections",
|
|
||||||
"gpui",
|
|
||||||
"log",
|
|
||||||
"rand 0.8.3",
|
|
||||||
"smallvec",
|
|
||||||
"sum_tree",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "build_const"
|
name = "build_const"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@ -1541,7 +1526,6 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"buffer",
|
|
||||||
"clock",
|
"clock",
|
||||||
"ctor",
|
"ctor",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
@ -1557,6 +1541,7 @@ dependencies = [
|
|||||||
"smallvec",
|
"smallvec",
|
||||||
"smol",
|
"smol",
|
||||||
"sum_tree",
|
"sum_tree",
|
||||||
|
"text",
|
||||||
"theme",
|
"theme",
|
||||||
"tree-sitter",
|
"tree-sitter",
|
||||||
"tree-sitter-rust",
|
"tree-sitter-rust",
|
||||||
@ -2107,10 +2092,10 @@ dependencies = [
|
|||||||
name = "go_to_line"
|
name = "go_to_line"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"buffer",
|
|
||||||
"editor",
|
"editor",
|
||||||
"gpui",
|
"gpui",
|
||||||
"postage",
|
"postage",
|
||||||
|
"text",
|
||||||
"workspace",
|
"workspace",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -2589,7 +2574,6 @@ name = "language"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"buffer",
|
|
||||||
"clock",
|
"clock",
|
||||||
"futures",
|
"futures",
|
||||||
"gpui",
|
"gpui",
|
||||||
@ -2603,6 +2587,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"similar",
|
"similar",
|
||||||
"smol",
|
"smol",
|
||||||
|
"text",
|
||||||
"theme",
|
"theme",
|
||||||
"tree-sitter",
|
"tree-sitter",
|
||||||
"tree-sitter-rust",
|
"tree-sitter-rust",
|
||||||
@ -3451,7 +3436,6 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"buffer",
|
|
||||||
"client",
|
"client",
|
||||||
"clock",
|
"clock",
|
||||||
"fsevent",
|
"fsevent",
|
||||||
@ -3474,6 +3458,7 @@ dependencies = [
|
|||||||
"smol",
|
"smol",
|
||||||
"sum_tree",
|
"sum_tree",
|
||||||
"tempdir",
|
"tempdir",
|
||||||
|
"text",
|
||||||
"toml",
|
"toml",
|
||||||
"unindent",
|
"unindent",
|
||||||
"util",
|
"util",
|
||||||
@ -4856,6 +4841,21 @@ dependencies = [
|
|||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "text"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"arrayvec 0.7.1",
|
||||||
|
"clock",
|
||||||
|
"collections",
|
||||||
|
"gpui",
|
||||||
|
"log",
|
||||||
|
"rand 0.8.3",
|
||||||
|
"smallvec",
|
||||||
|
"sum_tree",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "textwrap"
|
name = "textwrap"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
@ -5676,7 +5676,6 @@ dependencies = [
|
|||||||
"async-recursion",
|
"async-recursion",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
"buffer",
|
|
||||||
"chat_panel",
|
"chat_panel",
|
||||||
"client",
|
"client",
|
||||||
"clock",
|
"clock",
|
||||||
@ -5721,6 +5720,7 @@ dependencies = [
|
|||||||
"sum_tree",
|
"sum_tree",
|
||||||
"surf",
|
"surf",
|
||||||
"tempdir",
|
"tempdir",
|
||||||
|
"text",
|
||||||
"theme",
|
"theme",
|
||||||
"theme_selector",
|
"theme_selector",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
@ -5,13 +5,13 @@ edition = "2018"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = [
|
test-support = [
|
||||||
"buffer/test-support",
|
"text/test-support",
|
||||||
"language/test-support",
|
"language/test-support",
|
||||||
"gpui/test-support",
|
"gpui/test-support",
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
buffer = { path = "../buffer" }
|
text = { path = "../text" }
|
||||||
clock = { path = "../clock" }
|
clock = { path = "../clock" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
language = { path = "../language" }
|
language = { path = "../language" }
|
||||||
@ -31,7 +31,7 @@ smallvec = { version = "1.6", features = ["union"] }
|
|||||||
smol = "1.2"
|
smol = "1.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
buffer = { path = "../buffer", features = ["test-support"] }
|
text = { path = "../text", features = ["test-support"] }
|
||||||
language = { path = "../language", features = ["test-support"] }
|
language = { path = "../language", features = ["test-support"] }
|
||||||
gpui = { path = "../gpui", features = ["test-support"] }
|
gpui = { path = "../gpui", features = ["test-support"] }
|
||||||
ctor = "0.1"
|
ctor = "0.1"
|
||||||
|
@ -6,7 +6,6 @@ mod wrap_map;
|
|||||||
|
|
||||||
pub use block_map::{BlockDisposition, BlockId, BlockProperties, BufferRows, Chunks};
|
pub use block_map::{BlockDisposition, BlockId, BlockProperties, BufferRows, Chunks};
|
||||||
use block_map::{BlockMap, BlockPoint};
|
use block_map::{BlockMap, BlockPoint};
|
||||||
use buffer::Rope;
|
|
||||||
use fold_map::{FoldMap, ToFoldPoint as _};
|
use fold_map::{FoldMap, ToFoldPoint as _};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
fonts::{FontId, HighlightStyle},
|
fonts::{FontId, HighlightStyle},
|
||||||
@ -19,6 +18,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
use sum_tree::Bias;
|
use sum_tree::Bias;
|
||||||
use tab_map::TabMap;
|
use tab_map::TabMap;
|
||||||
|
use text::Rope;
|
||||||
use theme::{BlockStyle, SyntaxTheme};
|
use theme::{BlockStyle, SyntaxTheme};
|
||||||
use wrap_map::WrapMap;
|
use wrap_map::WrapMap;
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ use super::{
|
|||||||
wrap_map::{self, Edit as WrapEdit, Snapshot as WrapSnapshot, WrapPoint},
|
wrap_map::{self, Edit as WrapEdit, Snapshot as WrapSnapshot, WrapPoint},
|
||||||
BlockStyle, DisplayRow,
|
BlockStyle, DisplayRow,
|
||||||
};
|
};
|
||||||
use buffer::{rope, Anchor, Bias, Edit, Point, Rope, ToOffset, ToPoint as _};
|
|
||||||
use gpui::{fonts::HighlightStyle, AppContext, ModelHandle};
|
use gpui::{fonts::HighlightStyle, AppContext, ModelHandle};
|
||||||
use language::{Buffer, Chunk};
|
use language::{Buffer, Chunk};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
@ -19,6 +18,7 @@ use std::{
|
|||||||
vec,
|
vec,
|
||||||
};
|
};
|
||||||
use sum_tree::SumTree;
|
use sum_tree::SumTree;
|
||||||
|
use text::{rope, Anchor, Bias, Edit, Point, Rope, ToOffset, ToPoint as _};
|
||||||
use theme::SyntaxTheme;
|
use theme::SyntaxTheme;
|
||||||
|
|
||||||
pub struct BlockMap {
|
pub struct BlockMap {
|
||||||
@ -1003,11 +1003,11 @@ fn offset_for_row(s: &str, target: u32) -> (u32, usize) {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::display_map::{fold_map::FoldMap, tab_map::TabMap, wrap_map::WrapMap};
|
use crate::display_map::{fold_map::FoldMap, tab_map::TabMap, wrap_map::WrapMap};
|
||||||
use buffer::RandomCharIter;
|
|
||||||
use gpui::color::Color;
|
use gpui::color::Color;
|
||||||
use language::Buffer;
|
use language::Buffer;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use text::RandomCharIter;
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_offset_for_row() {
|
fn test_offset_for_row() {
|
||||||
|
@ -110,7 +110,7 @@ impl<'a> FoldMapWriter<'a> {
|
|||||||
if range.start != range.end {
|
if range.start != range.end {
|
||||||
let fold = Fold(buffer.anchor_after(range.start)..buffer.anchor_before(range.end));
|
let fold = Fold(buffer.anchor_after(range.start)..buffer.anchor_before(range.end));
|
||||||
folds.push(fold);
|
folds.push(fold);
|
||||||
edits.push(buffer::Edit {
|
edits.push(text::Edit {
|
||||||
old: range.clone(),
|
old: range.clone(),
|
||||||
new: range,
|
new: range,
|
||||||
});
|
});
|
||||||
@ -154,7 +154,7 @@ impl<'a> FoldMapWriter<'a> {
|
|||||||
let mut folds_cursor = intersecting_folds(&buffer, &self.0.folds, range, true);
|
let mut folds_cursor = intersecting_folds(&buffer, &self.0.folds, range, true);
|
||||||
while let Some(fold) = folds_cursor.item() {
|
while let Some(fold) = folds_cursor.item() {
|
||||||
let offset_range = fold.0.start.to_offset(&buffer)..fold.0.end.to_offset(&buffer);
|
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(),
|
old: offset_range.clone(),
|
||||||
new: offset_range,
|
new: offset_range,
|
||||||
});
|
});
|
||||||
@ -285,11 +285,7 @@ impl FoldMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_edits(
|
fn apply_edits(&self, buffer_edits: Vec<text::Edit<usize>>, cx: &AppContext) -> Vec<FoldEdit> {
|
||||||
&self,
|
|
||||||
buffer_edits: Vec<buffer::Edit<usize>>,
|
|
||||||
cx: &AppContext,
|
|
||||||
) -> Vec<FoldEdit> {
|
|
||||||
let buffer = self.buffer.read(cx).snapshot();
|
let buffer = self.buffer.read(cx).snapshot();
|
||||||
let mut buffer_edits_iter = buffer_edits.iter().cloned().peekable();
|
let mut buffer_edits_iter = buffer_edits.iter().cloned().peekable();
|
||||||
|
|
||||||
@ -713,7 +709,7 @@ impl Snapshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn intersecting_folds<'a, T>(
|
fn intersecting_folds<'a, T>(
|
||||||
buffer: &'a buffer::Snapshot,
|
buffer: &'a text::Snapshot,
|
||||||
folds: &'a SumTree<Fold>,
|
folds: &'a SumTree<Fold>,
|
||||||
range: Range<T>,
|
range: Range<T>,
|
||||||
inclusive: bool,
|
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| {
|
edits.sort_unstable_by(|a, b| {
|
||||||
a.old
|
a.old
|
||||||
.start
|
.start
|
||||||
@ -864,9 +860,9 @@ impl Default for FoldSummary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl sum_tree::Summary 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 {
|
if other.min_start.cmp(&self.min_start, buffer).unwrap() == Ordering::Less {
|
||||||
self.min_start = other.min_start.clone();
|
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 {
|
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.start = summary.start.clone();
|
||||||
self.0.end = summary.end.clone();
|
self.0.end = summary.end.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> sum_tree::SeekTarget<'a, FoldSummary, Fold> for Fold {
|
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()
|
self.0.cmp(&other.0, buffer).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> sum_tree::Dimension<'a, FoldSummary> for usize {
|
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;
|
*self += summary.count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1078,9 +1074,9 @@ impl FoldEdit {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{test::sample_text, ToPoint};
|
use crate::{test::sample_text, ToPoint};
|
||||||
use buffer::RandomCharIter;
|
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use std::{env, mem};
|
use std::{env, mem};
|
||||||
|
use text::RandomCharIter;
|
||||||
use Bias::{Left, Right};
|
use Bias::{Left, Right};
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::{cmp, mem};
|
use std::{cmp, mem};
|
||||||
|
|
||||||
type Edit = buffer::Edit<u32>;
|
type Edit = text::Edit<u32>;
|
||||||
|
|
||||||
#[derive(Default, Debug, PartialEq, Eq)]
|
#[derive(Default, Debug, PartialEq, Eq)]
|
||||||
pub struct Patch(Vec<Edit>);
|
pub struct Patch(Vec<Edit>);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use super::fold_map::{self, FoldEdit, FoldPoint, Snapshot as FoldSnapshot, ToFoldPoint};
|
use super::fold_map::{self, FoldEdit, FoldPoint, Snapshot as FoldSnapshot, ToFoldPoint};
|
||||||
use buffer::Point;
|
|
||||||
use language::{rope, Chunk};
|
use language::{rope, Chunk};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::{cmp, mem, ops::Range};
|
use std::{cmp, mem, ops::Range};
|
||||||
use sum_tree::Bias;
|
use sum_tree::Bias;
|
||||||
|
use text::Point;
|
||||||
use theme::SyntaxTheme;
|
use theme::SyntaxTheme;
|
||||||
|
|
||||||
pub struct TabMap(Mutex<Snapshot>);
|
pub struct TabMap(Mutex<Snapshot>);
|
||||||
@ -451,9 +451,9 @@ impl<'a> Iterator for Chunks<'a> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::display_map::fold_map::FoldMap;
|
use crate::display_map::fold_map::FoldMap;
|
||||||
use buffer::{RandomCharIter, Rope};
|
|
||||||
use language::Buffer;
|
use language::Buffer;
|
||||||
use rand::{prelude::StdRng, Rng};
|
use rand::{prelude::StdRng, Rng};
|
||||||
|
use text::{RandomCharIter, Rope};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_expand_tabs() {
|
fn test_expand_tabs() {
|
||||||
|
@ -16,7 +16,7 @@ use sum_tree::{Bias, Cursor, SumTree};
|
|||||||
use theme::SyntaxTheme;
|
use theme::SyntaxTheme;
|
||||||
|
|
||||||
pub use super::tab_map::TextSummary;
|
pub use super::tab_map::TextSummary;
|
||||||
pub type Edit = buffer::Edit<u32>;
|
pub type Edit = text::Edit<u32>;
|
||||||
|
|
||||||
pub struct WrapMap {
|
pub struct WrapMap {
|
||||||
snapshot: Snapshot,
|
snapshot: Snapshot,
|
||||||
@ -991,10 +991,10 @@ mod tests {
|
|||||||
display_map::{fold_map::FoldMap, tab_map::TabMap},
|
display_map::{fold_map::FoldMap, tab_map::TabMap},
|
||||||
test::Observer,
|
test::Observer,
|
||||||
};
|
};
|
||||||
use buffer::Rope;
|
|
||||||
use language::{Buffer, RandomCharIter};
|
use language::{Buffer, RandomCharIter};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use std::{cmp, env};
|
use std::{cmp, env};
|
||||||
|
use text::Rope;
|
||||||
|
|
||||||
#[gpui::test(iterations = 100)]
|
#[gpui::test(iterations = 100)]
|
||||||
async fn test_random_wraps(mut cx: gpui::TestAppContext, mut rng: StdRng) {
|
async fn test_random_wraps(mut cx: gpui::TestAppContext, mut rng: StdRng) {
|
||||||
|
@ -931,7 +931,7 @@ pub struct LayoutState {
|
|||||||
line_height: f32,
|
line_height: f32,
|
||||||
em_width: f32,
|
em_width: f32,
|
||||||
em_advance: f32,
|
em_advance: f32,
|
||||||
selections: HashMap<ReplicaId, Vec<buffer::Selection<DisplayPoint>>>,
|
selections: HashMap<ReplicaId, Vec<text::Selection<DisplayPoint>>>,
|
||||||
overscroll: Vector2F,
|
overscroll: Vector2F,
|
||||||
text_offset: Vector2F,
|
text_offset: Vector2F,
|
||||||
max_visible_line_width: f32,
|
max_visible_line_width: f32,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use crate::{Editor, EditorSettings, Event};
|
use crate::{Editor, EditorSettings, Event};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use buffer::{Point, Selection, ToPoint};
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*, fonts::TextStyle, AppContext, Entity, ModelContext, ModelHandle,
|
elements::*, fonts::TextStyle, AppContext, Entity, ModelContext, ModelHandle,
|
||||||
MutableAppContext, RenderContext, Subscription, Task, View, ViewContext, ViewHandle,
|
MutableAppContext, RenderContext, Subscription, Task, View, ViewContext, ViewHandle,
|
||||||
@ -11,6 +10,7 @@ use postage::watch;
|
|||||||
use project::{ProjectPath, Worktree};
|
use project::{ProjectPath, Worktree};
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use text::{Point, Selection, ToPoint};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
settings, EntryOpener, ItemHandle, ItemView, ItemViewHandle, Settings, StatusItemView,
|
settings, EntryOpener, ItemHandle, ItemView, ItemViewHandle, Settings, StatusItemView,
|
||||||
WeakItemHandle,
|
WeakItemHandle,
|
||||||
|
@ -7,7 +7,6 @@ pub mod movement;
|
|||||||
mod test;
|
mod test;
|
||||||
|
|
||||||
use aho_corasick::AhoCorasick;
|
use aho_corasick::AhoCorasick;
|
||||||
use buffer::rope::TextDimension;
|
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use display_map::*;
|
use display_map::*;
|
||||||
pub use display_map::{DisplayPoint, DisplayRow};
|
pub use display_map::{DisplayPoint, DisplayRow};
|
||||||
@ -35,6 +34,7 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use sum_tree::Bias;
|
use sum_tree::Bias;
|
||||||
|
use text::rope::TextDimension;
|
||||||
use theme::{DiagnosticStyle, EditorStyle, SyntaxTheme};
|
use theme::{DiagnosticStyle, EditorStyle, SyntaxTheme};
|
||||||
use util::post_inc;
|
use util::post_inc;
|
||||||
use workspace::{EntryOpener, Workspace};
|
use workspace::{EntryOpener, Workspace};
|
||||||
@ -3731,7 +3731,7 @@ pub fn diagnostic_style(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::sample_text;
|
use crate::test::sample_text;
|
||||||
use buffer::Point;
|
use text::Point;
|
||||||
use unindent::Unindent;
|
use unindent::Unindent;
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::{Bias, DisplayMapSnapshot, DisplayPoint, SelectionGoal, ToDisplayPoint};
|
use super::{Bias, DisplayMapSnapshot, DisplayPoint, SelectionGoal, ToDisplayPoint};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use buffer::ToPoint;
|
|
||||||
use std::{cmp, ops::Range};
|
use std::{cmp, ops::Range};
|
||||||
|
use text::ToPoint;
|
||||||
|
|
||||||
pub fn left(map: &DisplayMapSnapshot, mut point: DisplayPoint) -> Result<DisplayPoint> {
|
pub fn left(map: &DisplayMapSnapshot, mut point: DisplayPoint) -> Result<DisplayPoint> {
|
||||||
if point.column() > 0 {
|
if point.column() > 0 {
|
||||||
|
@ -4,7 +4,7 @@ version = "0.1.0"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
buffer = { path = "../buffer" }
|
text = { path = "../text" }
|
||||||
editor = { path = "../editor" }
|
editor = { path = "../editor" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use buffer::{Bias, Point, Selection};
|
use text::{Bias, Point, Selection};
|
||||||
use editor::{display_map::ToDisplayPoint, Autoscroll, Editor, EditorSettings};
|
use editor::{display_map::ToDisplayPoint, Autoscroll, Editor, EditorSettings};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
action, elements::*, geometry::vector::Vector2F, keymap::Binding, Axis, Entity,
|
action, elements::*, geometry::vector::Vector2F, keymap::Binding, Axis, Entity,
|
||||||
|
@ -6,13 +6,13 @@ edition = "2018"
|
|||||||
[features]
|
[features]
|
||||||
test-support = [
|
test-support = [
|
||||||
"rand",
|
"rand",
|
||||||
"buffer/test-support",
|
"text/test-support",
|
||||||
"lsp/test-support",
|
"lsp/test-support",
|
||||||
"tree-sitter-rust",
|
"tree-sitter-rust",
|
||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
buffer = { path = "../buffer" }
|
text = { path = "../text" }
|
||||||
clock = { path = "../clock" }
|
clock = { path = "../clock" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
lsp = { path = "../lsp" }
|
lsp = { path = "../lsp" }
|
||||||
@ -33,7 +33,7 @@ tree-sitter = "0.19.5"
|
|||||||
tree-sitter-rust = { version = "0.19.0", optional = true }
|
tree-sitter-rust = { version = "0.19.0", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
buffer = { path = "../buffer", features = ["test-support"] }
|
text = { path = "../text", features = ["test-support"] }
|
||||||
gpui = { path = "../gpui", features = ["test-support"] }
|
gpui = { path = "../gpui", features = ["test-support"] }
|
||||||
lsp = { path = "../lsp", features = ["test-support"] }
|
lsp = { path = "../lsp", features = ["test-support"] }
|
||||||
rand = "0.8.3"
|
rand = "0.8.3"
|
||||||
|
@ -12,7 +12,6 @@ pub use self::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
pub use buffer::{Buffer as TextBuffer, Operation as _, *};
|
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use futures::FutureExt as _;
|
use futures::FutureExt as _;
|
||||||
use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, MutableAppContext, Task};
|
use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, MutableAppContext, Task};
|
||||||
@ -37,6 +36,7 @@ use std::{
|
|||||||
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
|
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
|
||||||
vec,
|
vec,
|
||||||
};
|
};
|
||||||
|
pub use text::{Buffer as TextBuffer, Operation as _, *};
|
||||||
use theme::SyntaxTheme;
|
use theme::SyntaxTheme;
|
||||||
use tree_sitter::{InputEdit, Parser, QueryCursor, Tree};
|
use tree_sitter::{InputEdit, Parser, QueryCursor, Tree};
|
||||||
use util::{post_inc, TryFutureExt as _};
|
use util::{post_inc, TryFutureExt as _};
|
||||||
@ -77,7 +77,7 @@ pub struct Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Snapshot {
|
pub struct Snapshot {
|
||||||
text: buffer::Snapshot,
|
text: text::Snapshot,
|
||||||
tree: Option<Tree>,
|
tree: Option<Tree>,
|
||||||
diagnostics: AnchorRangeMultimap<Diagnostic>,
|
diagnostics: AnchorRangeMultimap<Diagnostic>,
|
||||||
is_parsing: bool,
|
is_parsing: bool,
|
||||||
@ -102,14 +102,14 @@ struct LanguageServerState {
|
|||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct LanguageServerSnapshot {
|
struct LanguageServerSnapshot {
|
||||||
buffer_snapshot: buffer::Snapshot,
|
buffer_snapshot: text::Snapshot,
|
||||||
version: usize,
|
version: usize,
|
||||||
path: Arc<Path>,
|
path: Arc<Path>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum Operation {
|
pub enum Operation {
|
||||||
Buffer(buffer::Operation),
|
Buffer(text::Operation),
|
||||||
UpdateDiagnostics(AnchorRangeMultimap<Diagnostic>),
|
UpdateDiagnostics(AnchorRangeMultimap<Diagnostic>),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,11 +269,11 @@ impl Buffer {
|
|||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
let mut buffer =
|
let mut buffer =
|
||||||
buffer::Buffer::new(replica_id, message.id, History::new(message.content.into()));
|
text::Buffer::new(replica_id, message.id, History::new(message.content.into()));
|
||||||
let ops = message
|
let ops = message
|
||||||
.history
|
.history
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|op| buffer::Operation::Edit(proto::deserialize_edit_operation(op)));
|
.map(|op| text::Operation::Edit(proto::deserialize_edit_operation(op)));
|
||||||
buffer.apply_ops(ops)?;
|
buffer.apply_ops(ops)?;
|
||||||
for set in message.selections {
|
for set in message.selections {
|
||||||
let set = proto::deserialize_selection_set(set);
|
let set = proto::deserialize_selection_set(set);
|
||||||
@ -1321,7 +1321,7 @@ impl Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.end_transaction(None, cx).unwrap();
|
self.end_transaction(None, cx).unwrap();
|
||||||
self.send_operation(Operation::Buffer(buffer::Operation::Edit(edit)), cx);
|
self.send_operation(Operation::Buffer(text::Operation::Edit(edit)), cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn did_edit(
|
fn did_edit(
|
||||||
@ -1354,7 +1354,7 @@ impl Buffer {
|
|||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) -> SelectionSetId {
|
) -> SelectionSetId {
|
||||||
let operation = self.text.add_selection_set(selections);
|
let operation = self.text.add_selection_set(selections);
|
||||||
if let buffer::Operation::UpdateSelections { set_id, .. } = &operation {
|
if let text::Operation::UpdateSelections { set_id, .. } = &operation {
|
||||||
let set_id = *set_id;
|
let set_id = *set_id;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
self.send_operation(Operation::Buffer(operation), cx);
|
self.send_operation(Operation::Buffer(operation), cx);
|
||||||
@ -1746,7 +1746,7 @@ impl Clone for Snapshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for Snapshot {
|
impl Deref for Snapshot {
|
||||||
type Target = buffer::Snapshot;
|
type Target = text::Snapshot;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.text
|
&self.text
|
||||||
|
@ -4,20 +4,20 @@ use crate::Diagnostic;
|
|||||||
|
|
||||||
use super::Operation;
|
use super::Operation;
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use buffer::*;
|
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use lsp::DiagnosticSeverity;
|
use lsp::DiagnosticSeverity;
|
||||||
use rpc::proto;
|
use rpc::proto;
|
||||||
|
use text::*;
|
||||||
|
|
||||||
pub use proto::Buffer;
|
pub use proto::Buffer;
|
||||||
|
|
||||||
pub fn serialize_operation(operation: &Operation) -> proto::Operation {
|
pub fn serialize_operation(operation: &Operation) -> proto::Operation {
|
||||||
proto::Operation {
|
proto::Operation {
|
||||||
variant: Some(match operation {
|
variant: Some(match operation {
|
||||||
Operation::Buffer(buffer::Operation::Edit(edit)) => {
|
Operation::Buffer(text::Operation::Edit(edit)) => {
|
||||||
proto::operation::Variant::Edit(serialize_edit_operation(edit))
|
proto::operation::Variant::Edit(serialize_edit_operation(edit))
|
||||||
}
|
}
|
||||||
Operation::Buffer(buffer::Operation::Undo {
|
Operation::Buffer(text::Operation::Undo {
|
||||||
undo,
|
undo,
|
||||||
lamport_timestamp,
|
lamport_timestamp,
|
||||||
}) => proto::operation::Variant::Undo(proto::operation::Undo {
|
}) => proto::operation::Variant::Undo(proto::operation::Undo {
|
||||||
@ -43,7 +43,7 @@ pub fn serialize_operation(operation: &Operation) -> proto::Operation {
|
|||||||
.collect(),
|
.collect(),
|
||||||
version: From::from(&undo.version),
|
version: From::from(&undo.version),
|
||||||
}),
|
}),
|
||||||
Operation::Buffer(buffer::Operation::UpdateSelections {
|
Operation::Buffer(text::Operation::UpdateSelections {
|
||||||
set_id,
|
set_id,
|
||||||
selections,
|
selections,
|
||||||
lamport_timestamp,
|
lamport_timestamp,
|
||||||
@ -62,7 +62,7 @@ pub fn serialize_operation(operation: &Operation) -> proto::Operation {
|
|||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
}),
|
}),
|
||||||
Operation::Buffer(buffer::Operation::RemoveSelections {
|
Operation::Buffer(text::Operation::RemoveSelections {
|
||||||
set_id,
|
set_id,
|
||||||
lamport_timestamp,
|
lamport_timestamp,
|
||||||
}) => proto::operation::Variant::RemoveSelections(proto::operation::RemoveSelections {
|
}) => proto::operation::Variant::RemoveSelections(proto::operation::RemoveSelections {
|
||||||
@ -70,7 +70,7 @@ pub fn serialize_operation(operation: &Operation) -> proto::Operation {
|
|||||||
local_timestamp: set_id.value,
|
local_timestamp: set_id.value,
|
||||||
lamport_timestamp: lamport_timestamp.value,
|
lamport_timestamp: lamport_timestamp.value,
|
||||||
}),
|
}),
|
||||||
Operation::Buffer(buffer::Operation::SetActiveSelections {
|
Operation::Buffer(text::Operation::SetActiveSelections {
|
||||||
set_id,
|
set_id,
|
||||||
lamport_timestamp,
|
lamport_timestamp,
|
||||||
}) => proto::operation::Variant::SetActiveSelections(
|
}) => proto::operation::Variant::SetActiveSelections(
|
||||||
@ -155,9 +155,9 @@ pub fn deserialize_operation(message: proto::Operation) -> Result<Operation> {
|
|||||||
.ok_or_else(|| anyhow!("missing operation variant"))?
|
.ok_or_else(|| anyhow!("missing operation variant"))?
|
||||||
{
|
{
|
||||||
proto::operation::Variant::Edit(edit) => {
|
proto::operation::Variant::Edit(edit) => {
|
||||||
Operation::Buffer(buffer::Operation::Edit(deserialize_edit_operation(edit)))
|
Operation::Buffer(text::Operation::Edit(deserialize_edit_operation(edit)))
|
||||||
}
|
}
|
||||||
proto::operation::Variant::Undo(undo) => Operation::Buffer(buffer::Operation::Undo {
|
proto::operation::Variant::Undo(undo) => Operation::Buffer(text::Operation::Undo {
|
||||||
lamport_timestamp: clock::Lamport {
|
lamport_timestamp: clock::Lamport {
|
||||||
replica_id: undo.replica_id as ReplicaId,
|
replica_id: undo.replica_id as ReplicaId,
|
||||||
value: undo.lamport_timestamp,
|
value: undo.lamport_timestamp,
|
||||||
@ -211,7 +211,7 @@ pub fn deserialize_operation(message: proto::Operation) -> Result<Operation> {
|
|||||||
entries,
|
entries,
|
||||||
);
|
);
|
||||||
|
|
||||||
Operation::Buffer(buffer::Operation::UpdateSelections {
|
Operation::Buffer(text::Operation::UpdateSelections {
|
||||||
set_id: clock::Lamport {
|
set_id: clock::Lamport {
|
||||||
replica_id: message.replica_id as ReplicaId,
|
replica_id: message.replica_id as ReplicaId,
|
||||||
value: message.local_timestamp,
|
value: message.local_timestamp,
|
||||||
@ -224,7 +224,7 @@ pub fn deserialize_operation(message: proto::Operation) -> Result<Operation> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
proto::operation::Variant::RemoveSelections(message) => {
|
proto::operation::Variant::RemoveSelections(message) => {
|
||||||
Operation::Buffer(buffer::Operation::RemoveSelections {
|
Operation::Buffer(text::Operation::RemoveSelections {
|
||||||
set_id: clock::Lamport {
|
set_id: clock::Lamport {
|
||||||
replica_id: message.replica_id as ReplicaId,
|
replica_id: message.replica_id as ReplicaId,
|
||||||
value: message.local_timestamp,
|
value: message.local_timestamp,
|
||||||
@ -236,7 +236,7 @@ pub fn deserialize_operation(message: proto::Operation) -> Result<Operation> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
proto::operation::Variant::SetActiveSelections(message) => {
|
proto::operation::Variant::SetActiveSelections(message) => {
|
||||||
Operation::Buffer(buffer::Operation::SetActiveSelections {
|
Operation::Buffer(text::Operation::SetActiveSelections {
|
||||||
set_id: message.local_timestamp.map(|value| clock::Lamport {
|
set_id: message.local_timestamp.map(|value| clock::Lamport {
|
||||||
replica_id: message.replica_id as ReplicaId,
|
replica_id: message.replica_id as ReplicaId,
|
||||||
value,
|
value,
|
||||||
|
@ -4,10 +4,10 @@ version = "0.1.0"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = ["language/test-support", "buffer/test-support"]
|
test-support = ["language/test-support", "text/test-support"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
buffer = { path = "../buffer" }
|
text = { path = "../text" }
|
||||||
client = { path = "../client" }
|
client = { path = "../client" }
|
||||||
clock = { path = "../clock" }
|
clock = { path = "../clock" }
|
||||||
fsevent = { path = "../fsevent" }
|
fsevent = { path = "../fsevent" }
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use buffer::Rope;
|
|
||||||
use fsevent::EventStream;
|
use fsevent::EventStream;
|
||||||
use futures::{Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
use postage::prelude::Sink as _;
|
use postage::prelude::Sink as _;
|
||||||
@ -11,6 +10,7 @@ use std::{
|
|||||||
pin::Pin,
|
pin::Pin,
|
||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
|
use text::Rope;
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
pub trait Fs: Send + Sync {
|
pub trait Fs: Send + Sync {
|
||||||
|
@ -3004,7 +3004,6 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::fs::FakeFs;
|
use crate::fs::FakeFs;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use buffer::Point;
|
|
||||||
use client::test::{FakeHttpClient, FakeServer};
|
use client::test::{FakeHttpClient, FakeServer};
|
||||||
use fs::RealFs;
|
use fs::RealFs;
|
||||||
use language::{tree_sitter_rust, LanguageServerConfig};
|
use language::{tree_sitter_rust, LanguageServerConfig};
|
||||||
@ -3018,6 +3017,7 @@ mod tests {
|
|||||||
fmt::Write,
|
fmt::Write,
|
||||||
time::{SystemTime, UNIX_EPOCH},
|
time::{SystemTime, UNIX_EPOCH},
|
||||||
};
|
};
|
||||||
|
use text::Point;
|
||||||
use util::test::temp_tree;
|
use util::test::temp_tree;
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
@ -3559,8 +3559,8 @@ mod tests {
|
|||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_buffer_file_changes_on_disk(mut cx: gpui::TestAppContext) {
|
async fn test_buffer_file_changes_on_disk(mut cx: gpui::TestAppContext) {
|
||||||
use buffer::{Point, Selection, SelectionGoal};
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
use text::{Point, Selection, SelectionGoal};
|
||||||
|
|
||||||
let initial_contents = "aaa\nbbbbb\nc\n";
|
let initial_contents = "aaa\nbbbbb\nc\n";
|
||||||
let dir = temp_tree(json!({ "the-file": initial_contents }));
|
let dir = temp_tree(json!({ "the-file": initial_contents }));
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "buffer"
|
name = "text"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/text.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = ["rand"]
|
test-support = ["rand"]
|
||||||
|
|
@ -15,7 +15,7 @@ path = "src/main.rs"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = [
|
test-support = [
|
||||||
"buffer/test-support",
|
"text/test-support",
|
||||||
"client/test-support",
|
"client/test-support",
|
||||||
"editor/test-support",
|
"editor/test-support",
|
||||||
"gpui/test-support",
|
"gpui/test-support",
|
||||||
@ -28,7 +28,7 @@ test-support = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
buffer = { path = "../buffer" }
|
text = { path = "../text" }
|
||||||
chat_panel = { path = "../chat_panel" }
|
chat_panel = { path = "../chat_panel" }
|
||||||
client = { path = "../client" }
|
client = { path = "../client" }
|
||||||
clock = { path = "../clock" }
|
clock = { path = "../clock" }
|
||||||
@ -89,7 +89,7 @@ tree-sitter-rust = "0.19.0"
|
|||||||
url = "2.2"
|
url = "2.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
buffer = { path = "../buffer", features = ["test-support"] }
|
text = { path = "../text", features = ["test-support"] }
|
||||||
editor = { path = "../editor", features = ["test-support"] }
|
editor = { path = "../editor", features = ["test-support"] }
|
||||||
gpui = { path = "../gpui", features = ["test-support"] }
|
gpui = { path = "../gpui", features = ["test-support"] }
|
||||||
language = { path = "../language", features = ["test-support"] }
|
language = { path = "../language", features = ["test-support"] }
|
||||||
|
Loading…
Reference in New Issue
Block a user