summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Prokopec <axel22@gmail.com>2012-05-18 17:35:20 +0200
committerAleksandar Prokopec <axel22@gmail.com>2012-05-18 17:35:20 +0200
commit093075a2f771e8f2b993d2ac808edbb7e4027657 (patch)
treedf8c5779aba53de91b92fab7c7e599f946ff203b
parent34fa132820ddef5d789dd6efd00dc2f3a1d27a63 (diff)
downloadscala-093075a2f771e8f2b993d2ac808edbb7e4027657.tar.gz
scala-093075a2f771e8f2b993d2ac808edbb7e4027657.tar.bz2
scala-093075a2f771e8f2b993d2ac808edbb7e4027657.zip
Fixes SI-4461.
No review.
-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
}
}