File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed
Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ declare module 'ot' {
22 export type SerializedTextOperation = ( string | number ) [ ] ;
33
44 class TextOperation {
5+ ops : SerializedTextOperation ;
6+
57 delete ( length : number ) : TextOperation ;
68 insert ( str : string ) : TextOperation ;
79 retain ( length : number ) : TextOperation ;
Original file line number Diff line number Diff line change @@ -393,6 +393,14 @@ class Live {
393393 return ;
394394 }
395395
396+ if ( operation . ops . length === 1 ) {
397+ const [ op ] = operation . ops ;
398+ if ( typeof op === 'number' ) {
399+ // Useless to send a single retain operation, ignore
400+ return ;
401+ }
402+ }
403+
396404 if ( moduleShortid . startsWith ( OPTIMISTIC_ID_PREFIX ) ) {
397405 // Module is an optimistic module, we will send a full code update
398406 // once the module has been created, until then, send nothing!
Original file line number Diff line number Diff line change @@ -691,7 +691,6 @@ export const moduleCreated: AsyncAction<{
691691 actions . editor . internal . setCurrentModule ( module ) ;
692692
693693 try {
694- const savedCode = module . code ;
695694 const updatedModule = await effects . api . createModule ( sandbox . id , module ) ;
696695
697696 module . id = updatedModule . id ;
@@ -710,7 +709,7 @@ export const moduleCreated: AsyncAction<{
710709 // Update server with latest data
711710 effects . live . sendCodeUpdate (
712711 module . shortid ,
713- getTextOperation ( savedCode || '' , module . code )
712+ getTextOperation ( updatedModule . code || '' , module . code )
714713 ) ;
715714 }
716715 } catch ( error ) {
You can’t perform that action at this time.
0 commit comments