Finished refactoring out fs and rope
This commit is contained in:
parent
0a8e2f6bb0
commit
0beb97547e
58 changed files with 328 additions and 223 deletions
|
@ -25,9 +25,11 @@ client = { path = "../client" }
|
|||
clock = { path = "../clock" }
|
||||
collections = { path = "../collections" }
|
||||
fuzzy = { path = "../fuzzy" }
|
||||
fs = { path = "../fs" }
|
||||
git = { path = "../git" }
|
||||
gpui = { path = "../gpui" }
|
||||
lsp = { path = "../lsp" }
|
||||
rope = { path = "../rope" }
|
||||
rpc = { path = "../rpc" }
|
||||
settings = { path = "../settings" }
|
||||
sum_tree = { path = "../sum_tree" }
|
||||
|
|
|
@ -13,9 +13,11 @@ use crate::{
|
|||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
use clock::ReplicaId;
|
||||
use fs::LineEnding;
|
||||
use futures::FutureExt as _;
|
||||
use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, MutableAppContext, Task};
|
||||
use parking_lot::Mutex;
|
||||
use rope::point::Point;
|
||||
use settings::Settings;
|
||||
use similar::{ChangeTag, TextDiff};
|
||||
use smol::future::yield_now;
|
||||
|
@ -38,7 +40,7 @@ use sum_tree::TreeMap;
|
|||
use text::operation_queue::OperationQueue;
|
||||
pub use text::{Buffer as TextBuffer, BufferSnapshot as TextBufferSnapshot, Operation as _, *};
|
||||
use theme::SyntaxTheme;
|
||||
use util::TryFutureExt as _;
|
||||
use util::{RandomCharIter, TryFutureExt as _};
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub use {tree_sitter_rust, tree_sitter_typescript};
|
||||
|
@ -368,7 +370,7 @@ impl Buffer {
|
|||
file,
|
||||
);
|
||||
this.text.set_line_ending(proto::deserialize_line_ending(
|
||||
proto::LineEnding::from_i32(message.line_ending)
|
||||
rpc::proto::LineEnding::from_i32(message.line_ending)
|
||||
.ok_or_else(|| anyhow!("missing line_ending"))?,
|
||||
));
|
||||
Ok(this)
|
||||
|
@ -1633,9 +1635,7 @@ impl Buffer {
|
|||
last_end = Some(range.end);
|
||||
|
||||
let new_text_len = rng.gen_range(0..10);
|
||||
let new_text: String = crate::random_char_iter::RandomCharIter::new(&mut *rng)
|
||||
.take(new_text_len)
|
||||
.collect();
|
||||
let new_text: String = RandomCharIter::new(&mut *rng).take(new_text_len).collect();
|
||||
|
||||
edits.push((range, new_text));
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
use super::*;
|
||||
use clock::ReplicaId;
|
||||
use collections::BTreeMap;
|
||||
use fs::LineEnding;
|
||||
use gpui::{ModelHandle, MutableAppContext};
|
||||
use proto::deserialize_operation;
|
||||
use rand::prelude::*;
|
||||
use rope::point::Point;
|
||||
use settings::Settings;
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
|
@ -14,7 +16,7 @@ use std::{
|
|||
};
|
||||
use text::network::Network;
|
||||
use unindent::Unindent as _;
|
||||
use util::{post_inc, test::marked_text_ranges};
|
||||
use util::{post_inc, test::marked_text_ranges, RandomCharIter};
|
||||
|
||||
#[cfg(test)]
|
||||
#[ctor::ctor]
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use crate::Diagnostic;
|
||||
use collections::HashMap;
|
||||
use rope::point_utf16::PointUtf16;
|
||||
use std::{
|
||||
cmp::{Ordering, Reverse},
|
||||
iter,
|
||||
ops::Range,
|
||||
};
|
||||
use sum_tree::{self, Bias, SumTree};
|
||||
use text::{Anchor, FromAnchor, PointUtf16, ToOffset};
|
||||
use text::{Anchor, FromAnchor, ToOffset};
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct DiagnosticSet {
|
||||
|
|
|
@ -22,6 +22,7 @@ use lazy_static::lazy_static;
|
|||
use parking_lot::{Mutex, RwLock};
|
||||
use postage::watch;
|
||||
use regex::Regex;
|
||||
use rope::point_utf16::PointUtf16;
|
||||
use serde::{de, Deserialize, Deserializer};
|
||||
use serde_json::Value;
|
||||
use std::{
|
||||
|
|
|
@ -8,19 +8,19 @@ use rpc::proto;
|
|||
use std::{ops::Range, sync::Arc};
|
||||
use text::*;
|
||||
|
||||
pub use proto::{BufferState, LineEnding, Operation, SelectionSet};
|
||||
pub use proto::{BufferState, Operation, SelectionSet};
|
||||
|
||||
pub fn deserialize_line_ending(message: proto::LineEnding) -> text::LineEnding {
|
||||
pub fn deserialize_line_ending(message: proto::LineEnding) -> fs::LineEnding {
|
||||
match message {
|
||||
LineEnding::Unix => text::LineEnding::Unix,
|
||||
LineEnding::Windows => text::LineEnding::Windows,
|
||||
proto::LineEnding::Unix => fs::LineEnding::Unix,
|
||||
proto::LineEnding::Windows => fs::LineEnding::Windows,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn serialize_line_ending(message: text::LineEnding) -> proto::LineEnding {
|
||||
pub fn serialize_line_ending(message: fs::LineEnding) -> proto::LineEnding {
|
||||
match message {
|
||||
text::LineEnding::Unix => proto::LineEnding::Unix,
|
||||
text::LineEnding::Windows => proto::LineEnding::Windows,
|
||||
fs::LineEnding::Unix => proto::LineEnding::Unix,
|
||||
fs::LineEnding::Windows => proto::LineEnding::Windows,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::{Grammar, InjectionConfig, Language, LanguageRegistry};
|
||||
use lazy_static::lazy_static;
|
||||
use parking_lot::Mutex;
|
||||
use rope::point::Point;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
cell::RefCell,
|
||||
|
@ -10,7 +11,7 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
use sum_tree::{Bias, SeekTarget, SumTree};
|
||||
use text::{rope, Anchor, BufferSnapshot, OffsetRangeExt, Point, Rope, ToOffset, ToPoint};
|
||||
use text::{Anchor, BufferSnapshot, OffsetRangeExt, Rope, ToOffset, ToPoint};
|
||||
use tree_sitter::{
|
||||
Node, Parser, Query, QueryCapture, QueryCaptures, QueryCursor, QueryMatches, Tree,
|
||||
};
|
||||
|
@ -1242,7 +1243,7 @@ mod tests {
|
|||
use crate::LanguageConfig;
|
||||
use rand::rngs::StdRng;
|
||||
use std::env;
|
||||
use text::{Buffer, Point};
|
||||
use text::Buffer;
|
||||
use unindent::Unindent as _;
|
||||
use util::test::marked_text_ranges;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue