mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
Don't duplicate categories when unlisting
op !== operation in all iterations of this loop except the first, and using information from one operation to apply another one doesn't work very well. The fact that undefined cast to a number is NaN rather than 0 is very unhelpful :( Also fixed some commas that should be semicolons. Bug: 52238 Change-Id: I4138c023c955f2866881084506e24bb8b6db5a4d
This commit is contained in:
parent
4b4299ad69
commit
55aaf56038
|
@ -305,6 +305,7 @@ ve.dm.TransactionProcessor.processors.replace = function ( op ) {
|
||||||
insert = this.reversed ? op.remove : op.insert,
|
insert = this.reversed ? op.remove : op.insert,
|
||||||
removeMetadata = this.reversed ? op.insertMetadata : op.removeMetadata,
|
removeMetadata = this.reversed ? op.insertMetadata : op.removeMetadata,
|
||||||
insertMetadata = this.reversed ? op.removeMetadata : op.insertMetadata,
|
insertMetadata = this.reversed ? op.removeMetadata : op.insertMetadata,
|
||||||
|
retainMetadata = op.retainMetadata || 0,
|
||||||
removeLinearData = new ve.dm.ElementLinearData( this.document.getStore(), remove ),
|
removeLinearData = new ve.dm.ElementLinearData( this.document.getStore(), remove ),
|
||||||
insertLinearData = new ve.dm.ElementLinearData( this.document.getStore(), insert ),
|
insertLinearData = new ve.dm.ElementLinearData( this.document.getStore(), insert ),
|
||||||
removeIsContent = removeLinearData.isContentData(),
|
removeIsContent = removeLinearData.isContentData(),
|
||||||
|
@ -324,14 +325,14 @@ ve.dm.TransactionProcessor.processors.replace = function ( op ) {
|
||||||
scopeStart,
|
scopeStart,
|
||||||
scopeEnd,
|
scopeEnd,
|
||||||
opAdjustment = 0,
|
opAdjustment = 0,
|
||||||
opRemove, opInsert, opRemoveMetadata, opInsertMetadata;
|
opRemove, opInsert, opRemoveMetadata, opInsertMetadata, opRetainMetadata;
|
||||||
if ( removeIsContent && insertIsContent ) {
|
if ( removeIsContent && insertIsContent ) {
|
||||||
// Content replacement
|
// Content replacement
|
||||||
// Update the linear model
|
// Update the linear model
|
||||||
this.document.data.batchSplice( this.cursor, remove.length, insert );
|
this.document.data.batchSplice( this.cursor, remove.length, insert );
|
||||||
// Keep the meta linear model in sync
|
// Keep the meta linear model in sync
|
||||||
if ( removeMetadata !== undefined ) {
|
if ( removeMetadata !== undefined ) {
|
||||||
this.document.metadata.batchSplice( this.cursor + op.retainMetadata, removeMetadata.length, insertMetadata );
|
this.document.metadata.batchSplice( this.cursor + retainMetadata, removeMetadata.length, insertMetadata );
|
||||||
} else if ( insert.length > remove.length ) {
|
} else if ( insert.length > remove.length ) {
|
||||||
this.document.metadata.batchSplice( this.cursor + remove.length, 0, new Array( insert.length - remove.length ) );
|
this.document.metadata.batchSplice( this.cursor + remove.length, 0, new Array( insert.length - remove.length ) );
|
||||||
} else if ( insert.length < remove.length ) {
|
} else if ( insert.length < remove.length ) {
|
||||||
|
@ -381,13 +382,14 @@ ve.dm.TransactionProcessor.processors.replace = function ( op ) {
|
||||||
if ( operation.type === 'replace' ) {
|
if ( operation.type === 'replace' ) {
|
||||||
opRemove = this.reversed ? operation.insert : operation.remove;
|
opRemove = this.reversed ? operation.insert : operation.remove;
|
||||||
opInsert = this.reversed ? operation.remove : operation.insert;
|
opInsert = this.reversed ? operation.remove : operation.insert;
|
||||||
opRemoveMetadata = this.reversed ? operation.insertMetadata : operation.removeMetadata,
|
opRemoveMetadata = this.reversed ? operation.insertMetadata : operation.removeMetadata;
|
||||||
opInsertMetadata = this.reversed ? operation.removeMetadata : operation.insertMetadata,
|
opInsertMetadata = this.reversed ? operation.removeMetadata : operation.insertMetadata;
|
||||||
|
opRetainMetadata = operation.retainMetadata || 0;
|
||||||
// Update the linear model
|
// Update the linear model
|
||||||
this.document.data.batchSplice( this.cursor, opRemove.length, opInsert );
|
this.document.data.batchSplice( this.cursor, opRemove.length, opInsert );
|
||||||
// Keep the meta linear model in sync
|
// Keep the meta linear model in sync
|
||||||
if ( opRemoveMetadata !== undefined ) {
|
if ( opRemoveMetadata !== undefined ) {
|
||||||
this.document.metadata.batchSplice( this.cursor + op.retainMetadata, opRemoveMetadata.length, opInsertMetadata );
|
this.document.metadata.batchSplice( this.cursor + opRetainMetadata, opRemoveMetadata.length, opInsertMetadata );
|
||||||
} else if ( opInsert.length > opRemove.length ) {
|
} else if ( opInsert.length > opRemove.length ) {
|
||||||
this.document.metadata.batchSplice( this.cursor + opRemove.length, 0, new Array( opInsert.length - opRemove.length ) );
|
this.document.metadata.batchSplice( this.cursor + opRemove.length, 0, new Array( opInsert.length - opRemove.length ) );
|
||||||
} else if ( opInsert.length < opRemove.length ) {
|
} else if ( opInsert.length < opRemove.length ) {
|
||||||
|
|
Loading…
Reference in a new issue