fix compact bugs & update unit tests

This commit is contained in:
appflowy
2022-01-26 23:29:18 +08:00
parent 4cdf3e3e3e
commit 8eaec5e58c
26 changed files with 320 additions and 218 deletions

View File

@ -1,6 +1,6 @@
use crate::core::{trim, Attributes, Delta, PlainTextAttributes};
use crate::core::{trim, Attributes, Delta, PlainAttributes};
pub type PlainDeltaBuilder = DeltaBuilder<PlainTextAttributes>;
pub type PlainDeltaBuilder = DeltaBuilder<PlainAttributes>;
pub struct DeltaBuilder<T: Attributes> {
delta: Delta<T>,

View File

@ -13,7 +13,7 @@ use std::{
str::FromStr,
};
pub type PlainDelta = Delta<PlainTextAttributes>;
pub type PlainDelta = Delta<PlainAttributes>;
// TODO: optimize the memory usage with Arc::make_mut or Cow
#[derive(Clone, Debug, PartialEq, Eq)]

View File

@ -1,10 +1,10 @@
use crate::{
core::{Attributes, Operation, PlainTextAttributes},
core::{Attributes, Operation, PlainAttributes},
rich_text::RichTextAttributes,
};
pub type RichTextOpBuilder = OpBuilder<RichTextAttributes>;
pub type PlainTextOpBuilder = OpBuilder<PlainTextAttributes>;
pub type PlainTextOpBuilder = OpBuilder<PlainAttributes>;
pub struct OpBuilder<T: Attributes> {
ty: Operation<T>,

View File

@ -339,14 +339,14 @@ where
}
#[derive(Debug, Clone, Eq, PartialEq, Default, Serialize, Deserialize)]
pub struct PlainTextAttributes();
impl fmt::Display for PlainTextAttributes {
pub struct PlainAttributes();
impl fmt::Display for PlainAttributes {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("PlainTextAttributes")
f.write_str("PlainAttributes")
}
}
impl Attributes for PlainTextAttributes {
impl Attributes for PlainAttributes {
fn is_empty(&self) -> bool {
true
}
@ -356,7 +356,7 @@ impl Attributes for PlainTextAttributes {
fn extend_other(&mut self, _other: Self) {}
}
impl OperationTransformable for PlainTextAttributes {
impl OperationTransformable for PlainAttributes {
fn compose(&self, _other: &Self) -> Result<Self, OTError> {
Ok(self.clone())
}