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
31 changed files with 84 additions and 85 deletions
|
@ -6,13 +6,13 @@ edition = "2018"
|
|||
[features]
|
||||
test-support = [
|
||||
"rand",
|
||||
"buffer/test-support",
|
||||
"text/test-support",
|
||||
"lsp/test-support",
|
||||
"tree-sitter-rust",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
buffer = { path = "../buffer" }
|
||||
text = { path = "../text" }
|
||||
clock = { path = "../clock" }
|
||||
gpui = { path = "../gpui" }
|
||||
lsp = { path = "../lsp" }
|
||||
|
@ -33,7 +33,7 @@ tree-sitter = "0.19.5"
|
|||
tree-sitter-rust = { version = "0.19.0", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
buffer = { path = "../buffer", features = ["test-support"] }
|
||||
text = { path = "../text", features = ["test-support"] }
|
||||
gpui = { path = "../gpui", features = ["test-support"] }
|
||||
lsp = { path = "../lsp", features = ["test-support"] }
|
||||
rand = "0.8.3"
|
||||
|
|
|
@ -12,7 +12,6 @@ pub use self::{
|
|||
},
|
||||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
pub use buffer::{Buffer as TextBuffer, Operation as _, *};
|
||||
use clock::ReplicaId;
|
||||
use futures::FutureExt as _;
|
||||
use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, MutableAppContext, Task};
|
||||
|
@ -37,6 +36,7 @@ use std::{
|
|||
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
|
||||
vec,
|
||||
};
|
||||
pub use text::{Buffer as TextBuffer, Operation as _, *};
|
||||
use theme::SyntaxTheme;
|
||||
use tree_sitter::{InputEdit, Parser, QueryCursor, Tree};
|
||||
use util::{post_inc, TryFutureExt as _};
|
||||
|
@ -77,7 +77,7 @@ pub struct Buffer {
|
|||
}
|
||||
|
||||
pub struct Snapshot {
|
||||
text: buffer::Snapshot,
|
||||
text: text::Snapshot,
|
||||
tree: Option<Tree>,
|
||||
diagnostics: AnchorRangeMultimap<Diagnostic>,
|
||||
is_parsing: bool,
|
||||
|
@ -102,14 +102,14 @@ struct LanguageServerState {
|
|||
|
||||
#[derive(Clone)]
|
||||
struct LanguageServerSnapshot {
|
||||
buffer_snapshot: buffer::Snapshot,
|
||||
buffer_snapshot: text::Snapshot,
|
||||
version: usize,
|
||||
path: Arc<Path>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Operation {
|
||||
Buffer(buffer::Operation),
|
||||
Buffer(text::Operation),
|
||||
UpdateDiagnostics(AnchorRangeMultimap<Diagnostic>),
|
||||
}
|
||||
|
||||
|
@ -269,11 +269,11 @@ impl Buffer {
|
|||
cx: &mut ModelContext<Self>,
|
||||
) -> Result<Self> {
|
||||
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
|
||||
.history
|
||||
.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)?;
|
||||
for set in message.selections {
|
||||
let set = proto::deserialize_selection_set(set);
|
||||
|
@ -1321,7 +1321,7 @@ impl Buffer {
|
|||
}
|
||||
|
||||
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(
|
||||
|
@ -1354,7 +1354,7 @@ impl Buffer {
|
|||
cx: &mut ModelContext<Self>,
|
||||
) -> SelectionSetId {
|
||||
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;
|
||||
cx.notify();
|
||||
self.send_operation(Operation::Buffer(operation), cx);
|
||||
|
@ -1746,7 +1746,7 @@ impl Clone for Snapshot {
|
|||
}
|
||||
|
||||
impl Deref for Snapshot {
|
||||
type Target = buffer::Snapshot;
|
||||
type Target = text::Snapshot;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.text
|
||||
|
|
|
@ -4,20 +4,20 @@ use crate::Diagnostic;
|
|||
|
||||
use super::Operation;
|
||||
use anyhow::{anyhow, Result};
|
||||
use buffer::*;
|
||||
use clock::ReplicaId;
|
||||
use lsp::DiagnosticSeverity;
|
||||
use rpc::proto;
|
||||
use text::*;
|
||||
|
||||
pub use proto::Buffer;
|
||||
|
||||
pub fn serialize_operation(operation: &Operation) -> proto::Operation {
|
||||
proto::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))
|
||||
}
|
||||
Operation::Buffer(buffer::Operation::Undo {
|
||||
Operation::Buffer(text::Operation::Undo {
|
||||
undo,
|
||||
lamport_timestamp,
|
||||
}) => proto::operation::Variant::Undo(proto::operation::Undo {
|
||||
|
@ -43,7 +43,7 @@ pub fn serialize_operation(operation: &Operation) -> proto::Operation {
|
|||
.collect(),
|
||||
version: From::from(&undo.version),
|
||||
}),
|
||||
Operation::Buffer(buffer::Operation::UpdateSelections {
|
||||
Operation::Buffer(text::Operation::UpdateSelections {
|
||||
set_id,
|
||||
selections,
|
||||
lamport_timestamp,
|
||||
|
@ -62,7 +62,7 @@ pub fn serialize_operation(operation: &Operation) -> proto::Operation {
|
|||
})
|
||||
.collect(),
|
||||
}),
|
||||
Operation::Buffer(buffer::Operation::RemoveSelections {
|
||||
Operation::Buffer(text::Operation::RemoveSelections {
|
||||
set_id,
|
||||
lamport_timestamp,
|
||||
}) => proto::operation::Variant::RemoveSelections(proto::operation::RemoveSelections {
|
||||
|
@ -70,7 +70,7 @@ pub fn serialize_operation(operation: &Operation) -> proto::Operation {
|
|||
local_timestamp: set_id.value,
|
||||
lamport_timestamp: lamport_timestamp.value,
|
||||
}),
|
||||
Operation::Buffer(buffer::Operation::SetActiveSelections {
|
||||
Operation::Buffer(text::Operation::SetActiveSelections {
|
||||
set_id,
|
||||
lamport_timestamp,
|
||||
}) => proto::operation::Variant::SetActiveSelections(
|
||||
|
@ -155,9 +155,9 @@ pub fn deserialize_operation(message: proto::Operation) -> Result<Operation> {
|
|||
.ok_or_else(|| anyhow!("missing operation variant"))?
|
||||
{
|
||||
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 {
|
||||
replica_id: undo.replica_id as ReplicaId,
|
||||
value: undo.lamport_timestamp,
|
||||
|
@ -211,7 +211,7 @@ pub fn deserialize_operation(message: proto::Operation) -> Result<Operation> {
|
|||
entries,
|
||||
);
|
||||
|
||||
Operation::Buffer(buffer::Operation::UpdateSelections {
|
||||
Operation::Buffer(text::Operation::UpdateSelections {
|
||||
set_id: clock::Lamport {
|
||||
replica_id: message.replica_id as ReplicaId,
|
||||
value: message.local_timestamp,
|
||||
|
@ -224,7 +224,7 @@ pub fn deserialize_operation(message: proto::Operation) -> Result<Operation> {
|
|||
})
|
||||
}
|
||||
proto::operation::Variant::RemoveSelections(message) => {
|
||||
Operation::Buffer(buffer::Operation::RemoveSelections {
|
||||
Operation::Buffer(text::Operation::RemoveSelections {
|
||||
set_id: clock::Lamport {
|
||||
replica_id: message.replica_id as ReplicaId,
|
||||
value: message.local_timestamp,
|
||||
|
@ -236,7 +236,7 @@ pub fn deserialize_operation(message: proto::Operation) -> Result<Operation> {
|
|||
})
|
||||
}
|
||||
proto::operation::Variant::SetActiveSelections(message) => {
|
||||
Operation::Buffer(buffer::Operation::SetActiveSelections {
|
||||
Operation::Buffer(text::Operation::SetActiveSelections {
|
||||
set_id: message.local_timestamp.map(|value| clock::Lamport {
|
||||
replica_id: message.replica_id as ReplicaId,
|
||||
value,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue