summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-05-18 12:39:28 -0700
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-05-18 12:39:28 -0700
commit5b9bf3d7124e8ba6e27953fa5cc00367614ecf5b (patch)
treed79e83324a0fc612b68a6a6a11bb5f64e08eb646
parent6765cb0af5a9f9cedd5c71b052aa963d9d52e8dc (diff)
parent093075a2f771e8f2b993d2ac808edbb7e4027657 (diff)
downloadscala-5b9bf3d7124e8ba6e27953fa5cc00367614ecf5b.tar.gz
scala-5b9bf3d7124e8ba6e27953fa5cc00367614ecf5b.tar.bz2
scala-5b9bf3d7124e8ba6e27953fa5cc00367614ecf5b.zip
Merge pull request #574 from axel22/issue/4461
Fixes SI-4461.
-rw-r--r--src/library/scala/collection/mutable/ObservableBuffer.scala14
-rw-r--r--test/files/run/t4461.check6
-rw-r--r--test/files/run/t4461.scala4
3 files changed, 23 insertions, 1 deletions
diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala
index a619edf281..6b5079e402 100644
--- a/src/library/scala/collection/mutable/ObservableBuffer.scala
+++ b/src/library/scala/collection/mutable/ObservableBuffer.scala
@@ -70,4 +70,18 @@ trait ObservableBuffer[A] extends Buffer[A] with Publisher[Message[A] with Undoa
def undo() { throw new UnsupportedOperationException("cannot undo") }
})
}
+
+ abstract override def insertAll(n: Int, elems: collection.Traversable[A]) {
+ super.insertAll(n, elems)
+ var curr = n - 1
+ val msg = elems.foldLeft(new Script[A]() with Undoable {
+ def undo() { throw new UnsupportedOperationException("cannot undo") }
+ }) {
+ case (msg, elem) =>
+ curr += 1
+ msg += Include(Index(curr), elem)
+ }
+ publish(msg)
+ }
+
}
diff --git a/test/files/run/t4461.check b/test/files/run/t4461.check
index b05c7b5589..e9c01e769d 100644
--- a/test/files/run/t4461.check
+++ b/test/files/run/t4461.check
@@ -4,4 +4,8 @@ Include(End,3)
Include(End,4)
Include(End,5)
Include(End,6)
-Include(End,7) \ No newline at end of file
+Include(End,7)
+Script([1] Include(Index(7),8), [2] Include(Index(8),9), [3] Include(Index(9),10))
+Include(Start,0)
+Script([1] Include(Index(0),-2), [2] Include(Index(1),-1))
+Remove(Index(0),-2) \ No newline at end of file
diff --git a/test/files/run/t4461.scala b/test/files/run/t4461.scala
index 99da122f6b..adc9201313 100644
--- a/test/files/run/t4461.scala
+++ b/test/files/run/t4461.scala
@@ -15,5 +15,9 @@ object Test {
buf ++= ArrayBuffer(3, 4) // works
buf ++= List(5) // works
buf ++= collection.immutable.Vector(6, 7) // works
+ buf.insertAll(7, List(8, 9, 10))
+ 0 +=: buf
+ List(-2, -1) ++=: buf
+ buf remove 0
}
}