From 9eea942aa627cd0d2d9a996ec70a8e8b7760e7bc Mon Sep 17 00:00:00 2001
From: Kai Koehne <kai.koehne@nokia.com>
Date: Wed, 20 Oct 2010 14:28:29 +0200
Subject: [PATCH] QmlOutline: Fix reordering of array elements

Make sure that a comma is added when inserting array elements
into the array.

Task-number: QTCREATORBUG-2796
Reviewed-by: Erik Verbruggen
---
 src/libs/qmljs/qmljsrewriter.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libs/qmljs/qmljsrewriter.cpp b/src/libs/qmljs/qmljsrewriter.cpp
index aad4b650abf..f29beb104d0 100644
--- a/src/libs/qmljs/qmljsrewriter.cpp
+++ b/src/libs/qmljs/qmljsrewriter.cpp
@@ -665,13 +665,13 @@ Rewriter::Range Rewriter::addObject(UiArrayBinding *ast, const QString &content,
     QString textToInsert;
     if (insertAfter && insertAfter->member) {
         insertionPoint = insertAfter->member->lastSourceLocation().end();
-        textToInsert += QLatin1String("\n");
+        textToInsert = QLatin1String(",\n") + content;
     } else {
         insertionPoint = ast->lbracketToken.end();
+        textToInsert += QLatin1String("\n") + content + QLatin1Char(',');
     }
 
-    textToInsert += content;
-    m_changeSet->insert(insertionPoint, QLatin1String("\n") + textToInsert);
+    m_changeSet->insert(insertionPoint, textToInsert);
 
     return Range(insertionPoint, insertionPoint);
 }
-- 
GitLab