Catrope has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405833 )

Change subject: SurfaceSynchronizer: Also translate selections that are not 
mentioned in the change
......................................................................

SurfaceSynchronizer: Also translate selections that are not mentioned in the 
change

Otherwise, if a lot of content gets deleted, other authors' selections
will become out of bounds.

Change-Id: Ie1e1ac4385abf7bdf78b1f40c9394a001ae2f182
---
M src/dm/ve.dm.SurfaceSynchronizer.js
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/33/405833/1

diff --git a/src/dm/ve.dm.SurfaceSynchronizer.js 
b/src/dm/ve.dm.SurfaceSynchronizer.js
index 651f952..0f51f1b 100644
--- a/src/dm/ve.dm.SurfaceSynchronizer.js
+++ b/src/dm/ve.dm.SurfaceSynchronizer.js
@@ -142,6 +142,9 @@
        change.applyTo( this.surface );
        // HACK: After applyTo(), the selections are wrong and applying them 
could crash.
        // The only reason this doesn't happen is because everything that tries 
to do that uses setTimeout().
+       // Translate the selections that aren't going to be overwritten by 
change.selections
+       this.applyNewSelections( this.authorSelections, change );
+       // Apply the overwrites from change.selections
        this.applyNewSelections( change.selections );
 };
 
@@ -241,6 +244,7 @@
                        translatedSelection = newSelections[ authorId ];
                }
                if ( !translatedSelection.equals( this.authorSelections[ 
authorId ] ) ) {
+                       // This works correctly even if newSelections === 
this.authorSelections
                        this.authorSelections[ authorId ] = translatedSelection;
                        this.emit( 'authorSelect', authorId );
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/405833
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie1e1ac4385abf7bdf78b1f40c9394a001ae2f182
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <r...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to