File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -238,7 +238,8 @@ impl Loro {
238
238
///
239
239
#[ wasm_bindgen( js_name = "fromSnapshot" ) ]
240
240
pub fn from_snapshot ( snapshot : & [ u8 ] ) -> JsResult < Loro > {
241
- let doc = LoroDoc :: from_snapshot ( snapshot) ?;
241
+ let mut doc = LoroDoc :: from_snapshot ( snapshot) ?;
242
+ doc. start_auto_commit ( ) ;
242
243
Ok ( Loro ( doc) )
243
244
}
244
245
Original file line number Diff line number Diff line change @@ -129,6 +129,15 @@ describe("import", () => {
129
129
a . import ( b . exportFrom ( a . version ( ) ) ) ;
130
130
expect ( a . getText ( "text" ) . toString ( ) ) . toBe ( "abc" ) ;
131
131
} ) ;
132
+
133
+ it ( "from snapshot" , ( ) => {
134
+ const a = new Loro ( ) ;
135
+ a . getText ( "text" ) . insert ( 0 , "hello" ) ;
136
+ const bytes = a . exportSnapshot ( ) ;
137
+ const b = Loro . fromSnapshot ( bytes ) ;
138
+ b . getText ( "text" ) . insert ( 0 , "123" ) ;
139
+ expect ( b . toJson ( ) ) . toStrictEqual ( { "text" : "123hello" } )
140
+ } )
132
141
} ) ;
133
142
134
143
describe ( "map" , ( ) => {
You can’t perform that action at this time.
0 commit comments