Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: workaround lldb bug make loro crate debuggable #414

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/loro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ keywords = ["crdt", "local-first"]
[dependencies]
loro-internal = { path = "../loro-internal", version = "0.16.2" }
delta = { path = "../delta", package = "loro-delta", version = "0.16.2" }
generic-btree = { version = "0.10.5" }
generic-btree = { version = "^0.10.5" }
enum-as-inner = "0.6.0"
either = "1.9.0"
tracing = "0.1"
Expand Down
24 changes: 17 additions & 7 deletions crates/loro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ pub use counter::LoroCounter;
/// `LoroDoc` is the entry for the whole document.
/// When it's dropped, all the associated [`Handler`]s will be invalidated.
#[derive(Debug)]
#[repr(transparent)]
pub struct LoroDoc {
doc: InnerLoroDoc,
#[cfg(debug_assertions)]
_temp: u8,
}

impl Default for LoroDoc {
Expand All @@ -69,23 +70,32 @@ impl Default for LoroDoc {
}

impl LoroDoc {
#[inline(always)]
fn _new(doc: InnerLoroDoc) -> Self {
Self {
doc,
#[cfg(debug_assertions)]
_temp: 0,
}
}

/// Create a new `LoroDoc` instance.
pub fn new() -> Self {
let doc = InnerLoroDoc::default();
doc.start_auto_commit();

LoroDoc { doc }
LoroDoc::_new(doc)
}

/// Duplicate the document with a different PeerID
///
/// The time complexity and space complexity of this operation are both O(n),
pub fn fork(&self) -> Self {
let doc = self.doc.fork();
LoroDoc { doc }
LoroDoc::_new(doc)
}

/// Get the configureations of the document.
/// Get the configurations of the document.
pub fn config(&self) -> &Configure {
self.doc.config()
}
Expand All @@ -99,7 +109,7 @@ impl LoroDoc {
///
/// If enabled, the Unix timestamp will be recorded for each change automatically.
///
/// You can set each timestamp manually when commiting a change.
/// You can set each timestamp manually when committing a change.
///
/// NOTE: Timestamps are forced to be in ascending order.
/// If you commit a new change with a timestamp that is less than the existing one,
Expand All @@ -112,7 +122,7 @@ impl LoroDoc {
/// Set the interval of mergeable changes, in milliseconds.
///
/// If two continuous local changes are within the interval, they will be merged into one change.
/// The defualt value is 1000 seconds.
/// The default value is 1000 seconds.
#[inline]
pub fn set_change_merge_interval(&self, interval: i64) {
self.doc.set_change_merge_interval(interval);
Expand Down Expand Up @@ -156,7 +166,7 @@ impl LoroDoc {
/// > In a detached state, the document is not editable, and any `import` operations will be
/// > recorded in the `OpLog` without being applied to the `DocState`.
///
/// You should call `attach` to attach the `DocState` to the lastest version of `OpLog`.
/// You should call `attach` to attach the `DocState` to the latest version of `OpLog`.
pub fn checkout(&self, frontiers: &Frontiers) -> LoroResult<()> {
self.doc.checkout(frontiers)
}
Expand Down
Loading