SelectionInListModelView.st
changeset 6167 8106bb36e30e
parent 6165 79773ea4a039
child 6201 f62406ae4f1e
--- a/SelectionInListModelView.st	Mon Oct 14 20:55:41 2019 +0200
+++ b/SelectionInListModelView.st	Mon Oct 14 20:55:56 2019 +0200
@@ -2408,6 +2408,15 @@
     ^ selection notNil
 !
 
+indexOfElementForWhich:aBlock
+    1 to:self size do:[:idx |
+        (aBlock value:(self at:idx)) ifTrue:[^idx].
+    ].
+    ^ 0
+
+    "Created: / 06-10-2011 / 13:32:28 / cg"
+!
+
 isInSelection:aNumber
     "return true, if line, aNumber is in the selection
     "
@@ -2611,11 +2620,12 @@
 !
 
 selectElementForWhich:aBlock ifAbsent:exceptionalValue
-    1 to:self size do:[:idx |
-        (aBlock value:(self at:idx)) ifTrue:[
-            self selection:idx.
-            ^ self
-        ].
+    |idx|
+
+    idx := self indexOfElementForWhich:aBlock.
+    idx ~~ 0 ifTrue:[
+        self selection:idx.
+        ^ self
     ].
     ^ exceptionalValue value