From e77a75370839636459931278483f688760a7efca Mon Sep 17 00:00:00 2001
From: Kevin Jahns <kevin.jahns@rwth-aachen.de>
Date: Fri, 3 Jun 2016 19:04:47 +0200
Subject: [PATCH] fixed bug in array & richtext

---
 gulpfile.helper.js | 4 +++-
 src/Database.js    | 8 ++++++--
 src/SpecHelper.js  | 2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/gulpfile.helper.js b/gulpfile.helper.js
index bc66de9a..fd538272 100644
--- a/gulpfile.helper.js
+++ b/gulpfile.helper.js
@@ -48,7 +48,9 @@ module.exports = function (gulp, helperOptions) {
       .pipe(source(options.targetName))
       .pipe(buffer())
       .pipe($.sourcemaps.init({loadMaps: true}))
-      .pipe($.if(!options.debug, $.uglify()))
+      .pipe($.if(!options.debug, $.uglify().on('error', function(e) {
+        console.log('\x07',e.message, JSON.stringify(e)); return this.end()
+      })))
       .pipe($.sourcemaps.write('.'))
       .pipe(gulp.dest('./dist/')))
   })
diff --git a/src/Database.js b/src/Database.js
index 66c77a26..afad7c94 100644
--- a/src/Database.js
+++ b/src/Database.js
@@ -367,12 +367,16 @@ module.exports = function (Y /* :any */) {
           }
         }
         if (defined == null) {
-          var isGarbageCollected = yield* this.isGarbageCollected(op.id)
+          var opid = op.id
+          var isGarbageCollected = yield* this.isGarbageCollected(opid)
           if (!isGarbageCollected) {
             yield* Y.Struct[op.struct].execute.call(this, op)
             yield* this.addOperation(op)
             yield* this.store.operationAdded(this, op)
-
+            if (!Y.utils.compareIds(opid, op.id)) {
+              // operationAdded changed op
+              op = yield* this.getOperation(opid)
+            }
             // if insertion, try to combine with left
             yield* this.tryCombineWithLeft(op)
           }
diff --git a/src/SpecHelper.js b/src/SpecHelper.js
index 73cf1714..831a6622 100644
--- a/src/SpecHelper.js
+++ b/src/SpecHelper.js
@@ -74,7 +74,7 @@ function getRandomNumber (n) {
 g.getRandomNumber = getRandomNumber
 
 function getRandomString () {
-  var chars = 'abcdefäö'
+  var chars = 'abcdefghijklmnopqrstuvwxyzäüöABCDEFGHIJKLMNOPQRSTUVWXYZÄÜÖ'
   var char = chars[getRandomNumber(chars.length)] // ü\n\n\n\n\n\n\n'
   var length = getRandomNumber(7)
   var string = ''
-- 
GitLab