jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/405549 )
Change subject: SurfaceSynchronizer: Translate selections when unapplying
......................................................................
SurfaceSynchronizer: Translate selections when unapplying
Also document how hacky this selection management code is.
Bug: T185395
Change-Id: If5df0b5755e56f99ca981bcee88485a4b71ddd40
---
M src/dm/ve.dm.SurfaceSynchronizer.js
1 file changed, 6 insertions(+), 6 deletions(-)
Approvals:
Divec: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/dm/ve.dm.SurfaceSynchronizer.js
b/src/dm/ve.dm.SurfaceSynchronizer.js
index ddd679e..651f952 100644
--- a/src/dm/ve.dm.SurfaceSynchronizer.js
+++ b/src/dm/ve.dm.SurfaceSynchronizer.js
@@ -140,6 +140,8 @@
delete this.authorSelections[ authorId ];
}
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().
this.applyNewSelections( change.selections );
};
@@ -147,13 +149,11 @@
* @inheritdoc
*/
ve.dm.SurfaceSynchronizer.prototype.unapplyChange = function ( change ) {
- var authorId, nullSelections = {};
- // Author selections are potentially invalid now, null them all out
- for ( authorId in this.authorSelections ) {
- nullSelections[ authorId ] = new ve.dm.NullSelection( this.doc
);
- }
- this.applyNewSelections( nullSelections );
change.unapplyTo( this.surface );
+ // Translate all selections for what we just unapplied
+ // HACK: After unapplyTo(), 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().
+ this.applyNewSelections( this.authorSelections, change.reversed() );
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/405549
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If5df0b5755e56f99ca981bcee88485a4b71ddd40
Gerrit-PatchSet: 2
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Divec <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits