You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/Automerge/ChangeHash.swift
+4-5
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,6 @@ public struct ChangeHash: Equatable, Hashable, CustomDebugStringConvertible, Sen
12
12
}
13
13
14
14
publicextensionSet<ChangeHash>{
15
-
16
15
/// Transforms each `ChangeHash` in the set into its byte array (`[UInt8]`). This raw byte representation
17
16
/// captures the state of the document at a specific point in its history, allowing for efficient storage
18
17
/// and retrieval of document states.
@@ -25,16 +24,16 @@ public extension Set<ChangeHash> {
25
24
}
26
25
27
26
publicextensionData{
28
-
29
-
/// Interprets the data to return the data as a set of change hashes that represent a state within an Automerge document. If the data is not a multiple of 32 bytes, returns nil.
27
+
/// Interprets the data to return the data as a set of change hashes that represent a state within an Automerge
28
+
/// document. If the data is not a multiple of 32 bytes, returns nil.
@@ -641,7 +645,7 @@ public final class Document: @unchecked Sendable {
641
645
/// deleting.
642
646
/// - delete: The number of unicode scalars to delete from the `start` index.
643
647
/// If negative, the function deletes characters preceding `start` index, rather than following it.
644
-
/// - values: The characters to insert after the `start` index.
648
+
/// - value: The characters to insert after the `start` index.
645
649
///
646
650
/// With `spliceText`, the `start` and `delete` parameters represent integer distances of unicode scalars of the
647
651
/// Swift strings, not the counts of Characters (or grapheme clusters).
@@ -797,7 +801,8 @@ public final class Document: @unchecked Sendable {
797
801
///
798
802
/// - Parameters:
799
803
/// - obj: The identifier of the text object, represented by an ``ObjId``.
800
-
/// - position: The position within the text, represented by a ``Position`` enum which can be a ``Cursor`` or an `UInt64` as a fixed position.
804
+
/// - position: The position within the text, represented by a ``Position`` enum which can be a ``Cursor`` or an
805
+
/// `UInt64` as a fixed position.
801
806
/// - heads: A set of `ChangeHash` values that represents a point in time in the document's history.
802
807
/// - Returns: An array of `Mark` objects for the text object at the specified position.
803
808
///
@@ -811,16 +816,22 @@ public final class Document: @unchecked Sendable {
811
816
/// ```
812
817
///
813
818
/// ## Recommendation
819
+
///
814
820
/// Use this method to query the marks applied to a text object at a specific position.
815
-
/// This can be useful for retrieving ``Marks`` related to a character without traversing the full document.
821
+
/// This can be useful for retrieving the list of ``Automerge/Mark`` related to a character without
822
+
/// traversing the full document.
816
823
///
817
824
/// ## When to Use Cursor vs. Index
818
825
///
819
826
/// While you can specify the position either with a `Cursor` or an `Index`, there are important distinctions:
820
827
///
821
-
/// - **Cursor**: Use a `Cursor` when you need to track a position that might change over time due to edits in the text object. A `Cursor` provides a way to maintain a reference to a logical position within the text even if the text content changes, making it more robust in collaborative or frequently edited documents.
828
+
/// - **Cursor**: Use a `Cursor` when you need to track a position that might change over time due to edits in the
829
+
/// text object. A `Cursor` provides a way to maintain a reference to a logical position within the text even if the
830
+
/// text content changes, making it more robust in collaborative or frequently edited documents.
822
831
///
823
-
/// - **Index**: Use an `Index` when you have a fixed position and you are sure that the text content will not change, or changes are irrelevant to your current operation. An index is a straightforward approach for static text content.
832
+
/// - **Index**: Use an `Index` when you have a fixed position and you are sure that the text content will not
833
+
/// change, or changes are irrelevant to your current operation. An index is a straightforward approach for static
834
+
/// text content.
824
835
///
825
836
/// # See Also
826
837
/// ``marksAt(obj:position:)``
@@ -845,7 +856,8 @@ public final class Document: @unchecked Sendable {
845
856
///
846
857
/// - Parameters:
847
858
/// - obj: The identifier of the text object, represented by an ``ObjId``.
848
-
/// - position: The position within the text, represented by a ``Position`` enum which can be a ``Cursor`` or an `UInt64` as a fixed position.
859
+
/// - position: The position within the text, represented by a ``Position`` enum which can be a ``Cursor`` or an
860
+
/// `UInt64` as a fixed position.
849
861
/// - Returns: An array of `Mark` objects for the text object at the specified position.
850
862
/// - Note: This method retrieves marks from the latest version of the document.
851
863
/// If you need to specify a point in the document's history, refer to ``marksAt(obj:position:heads:)``.
@@ -861,15 +873,20 @@ public final class Document: @unchecked Sendable {
861
873
///
862
874
/// ## Recommendation
863
875
/// Use this method to query the marks applied to a text object at a specific position.
864
-
/// This can be useful for retrieving ``Marks`` related to a character without traversing the full document.
876
+
/// This can be useful for retrieving the list of ``Automerge/Mark`` related to a character without
877
+
/// traversing the full document.
865
878
///
866
879
/// ## When to Use Cursor vs. Index
867
880
///
868
881
/// While you can specify the position either with a `Cursor` or an `Index`, there are important distinctions:
869
882
///
870
-
/// - **Cursor**: Use a `Cursor` when you need to track a position that might change over time due to edits in the text object. A `Cursor` provides a way to maintain a reference to a logical position within the text even if the text content changes, making it more robust in collaborative or frequently edited documents.
883
+
/// - **Cursor**: Use a `Cursor` when you need to track a position that might change over time due to edits in the
884
+
/// text object. A `Cursor` provides a way to maintain a reference to a logical position within the text even if the
885
+
/// text content changes, making it more robust in collaborative or frequently edited documents.
871
886
///
872
-
/// - **Index**: Use an `Index` when you have a fixed position and you are sure that the text content will not change, or changes are irrelevant to your current operation. An index is a straightforward approach for static text content.
887
+
/// - **Index**: Use an `Index` when you have a fixed position and you are sure that the text content will not
888
+
/// change, or changes are irrelevant to your current operation. An index is a straightforward approach for static
889
+
/// text content.
873
890
///
874
891
/// # See Also
875
892
/// ``marksAt(obj:position:heads:)``
@@ -901,7 +918,7 @@ public final class Document: @unchecked Sendable {
901
918
/// The `save` function also compacts the memory footprint of an Automerge document and increments the result of
902
919
/// ``heads()``, which indicates a specific point in time for the history of the document.
903
920
publicfunc save()->Data{
904
-
returnlock{
921
+
lock{
905
922
sendObjectWillChange()
906
923
defer{sendObjectDidChange()}
907
924
returnself.doc.wrapErrors{
@@ -956,7 +973,7 @@ public final class Document: @unchecked Sendable {
956
973
/// - message: The message from the peer to update this document and sync state.
957
974
/// - Returns: An array of ``Patch`` that represent the changes applied from the peer.
0 commit comments