Merge "Fix indent action when acting on multiple list items"

This commit is contained in:
jenkins-bot 2013-05-13 17:49:00 +00:00 committed by Gerrit Code Review
commit 2dddb90731
2 changed files with 13 additions and 3 deletions

View file

@ -55,7 +55,7 @@ ve.IndentationAction.prototype.increase = function () {
for ( i = 0; i < groups.length; i++ ) {
group = groups[i];
if ( group.grandparent && group.grandparent.getType() === 'list' ) {
fragments.push( surfaceModel.getFragment( group.parent.getOuterRange(), true ) );
fragments.push( surfaceModel.getFragment( group.parent.getRange(), true ) );
increased = true;
}
}
@ -63,7 +63,7 @@ ve.IndentationAction.prototype.increase = function () {
// Process each fragment (their ranges are automatically adjusted on change)
for ( i = 0; i < fragments.length; i++ ) {
this.indentListItem(
documentModel.getNodeFromOffset( fragments[i].getRange().start + 1 )
documentModel.getNodeFromOffset( fragments[i].getRange().start )
);
}

View file

@ -36,7 +36,7 @@ function runIndentationChangeTest( assert, range, method, expectedSelection, exp
surface.destroy();
}
QUnit.test( 'decrease', 2, function ( assert ) {
QUnit.test( 'increase/decrease', 2, function ( assert ) {
var i,
cases = [
{
@ -70,6 +70,16 @@ QUnit.test( 'decrease', 2, function ( assert ) {
delete data[12].internal;
},
'msg': 'decrease indentation on Items 1 & 2'
},
{
'range': new ve.Range( 3, 19 ),
'method': 'increase',
'expectedSelection': new ve.Range( 5, 21 ),
'expectedData': function ( data ) {
data.splice( 0, 0, { 'type': 'list', 'attributes': { 'style': 'bullet' } }, { 'type': 'listItem' } );
data.splice( 23, 0, { 'type': '/list' }, { 'type': '/listItem' } );
},
'msg': 'increase indentation on Items 1 & 2'
}
];