bugfix in: #removeFromIndex:toIndex:
authorca
Thu, 07 Dec 2000 07:23:00 +0100
changeset 1899 d7c9a9dfdbf0
parent 1898 4239a343dbe6
child 1900 27372ea0db5f
bugfix in: #removeFromIndex:toIndex:
HierarchicalItem.st
--- a/HierarchicalItem.st	Thu Dec 07 06:48:04 2000 +0100
+++ b/HierarchicalItem.st	Thu Dec 07 07:23:00 2000 +0100
@@ -517,12 +517,26 @@
     ^ aList
 !
 
+removeFromIndex:startIndex
+    "remove the children from startIndex up to end of children
+    "
+    ^ self removeFromIndex:startIndex toIndex:(children size)
+!
+
 removeFromIndex:startIndex toIndex:stopIndex
     "remove the children from startIndex up to and including
      the child under stopIndex.
     "
-    self criticalDo:[
-        self basicRemoveFromIndex:startIndex toIndex:stopIndex
+    |noChildren stop|
+
+    noChildren := children size.
+
+    (startIndex <= stopIndex and:[startIndex <= noChildren]) ifTrue:[
+        stop := stopIndex min:noChildren.
+        
+        self criticalDo:[
+            self basicRemoveFromIndex:startIndex toIndex:stop
+        ]
     ].
 !
 
@@ -1597,5 +1611,5 @@
 !HierarchicalItem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.27 2000-11-16 13:18:12 tm Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.28 2000-12-07 06:23:00 ca Exp $'
 ! !