forked from qt-creator/qt-creator
QMLRewriter: Fix the very first child position case in member search
If we want to insert an object to the top (pos = -1), we should find the current first object, and return the last non-object item found before the first object. If there's no object, it will be automatically return the last non-object. Change-Id: Icf78b219af4c0735b7a05e0a8692202dada877fc Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -275,9 +275,6 @@ QmlJS::AST::UiObjectMemberList *QMLRewriter::searchMemberToInsertAfter(
|
||||
QmlJS::AST::UiObjectMemberList *QMLRewriter::searchChildrenToInsertAfter(
|
||||
QmlJS::AST::UiObjectMemberList *members, const PropertyNameList &propertyOrder, int pos)
|
||||
{
|
||||
if (pos < 0)
|
||||
return searchMemberToInsertAfter(members, propertyOrder);
|
||||
|
||||
// An empty property name should be available in the propertyOrder List, which is the right place
|
||||
// to define the objects there.
|
||||
const int objectDefinitionInsertionPoint = propertyOrder.indexOf(PropertyName());
|
||||
@@ -291,6 +288,8 @@ QmlJS::AST::UiObjectMemberList *QMLRewriter::searchChildrenToInsertAfter(
|
||||
int idx = -1;
|
||||
|
||||
if (QmlJS::AST::cast<QmlJS::AST::UiObjectDefinition *>(member)) {
|
||||
if (pos < 0)
|
||||
break;
|
||||
lastObjectDef = iter;
|
||||
if (objectPos++ == pos)
|
||||
break;
|
||||
|
Reference in New Issue
Block a user