SystemBrowser.st
branchjv
changeset 17218 95008a0da101
parent 17136 cb908d2ba02e
parent 17180 4ac997b21c39
child 18532 cccb41254edf
--- a/SystemBrowser.st	Thu Dec 22 23:11:18 2016 +0000
+++ b/SystemBrowser.st	Mon Dec 26 10:26:02 2016 +0000
@@ -3534,7 +3534,7 @@
     "launch a browser for all implementors of aSelector in
      the classes contained in aCollectionOfClasses and their metaclasses"
 
-    |list list2 rs selWithColon title top20 allSelectors choice but globalClass global globalName|
+    |list list2 rs selWithColon title top20 allSelectors choice but globalClass global globalName lcSelector|
 
     title := titleArg.
     list := self 
@@ -3553,11 +3553,25 @@
         list2 size == 0 ifTrue:[
             "/ self showNoneFound:title.
             "/ ^ self
+            lcSelector := aSelectorString asLowercase.
+            
             allSelectors := Set new.
             top20 := SortedCollection new.
-            top20 sortBlock:[:a :b | (a spellAgainst:aSelectorString) > (b spellAgainst:aSelectorString)].
+            top20 
+                sortBlock:[:a :b | 
+                    |isPrefixOfA isPrefixOfB aDist bDist|
+
+                    isPrefixOfA := (a asLowercase startsWith:lcSelector).
+                    isPrefixOfB := (b asLowercase startsWith:lcSelector).
+                    (isPrefixOfA and:[isPrefixOfB not])
+                    or:[ 
+                        aDist := (a spellAgainst:aSelectorString).
+                        bDist := (b spellAgainst:aSelectorString).
+                        (isPrefixOfA and:[isPrefixOfB and:[aDist > bDist]])     
+                        or:[ isPrefixOfB not and:[ aDist > bDist ]]]
+                ].
             Smalltalk allMethodsWithSelectorDo:[:eachMethod :eachSelector |
-                ((eachSelector asLowercase startsWith:aSelectorString) or:[(eachSelector spellAgainst:aSelectorString) > 50]) ifTrue:[    
+                ((eachSelector asLowercase startsWith:lcSelector) or:[(eachSelector spellAgainst:aSelectorString) > 50]) ifTrue:[    
                     (allSelectors includes:eachSelector) ifFalse:[
                         allSelectors add:eachSelector.
                         top20 add:eachSelector.
@@ -3566,9 +3580,6 @@
                 ]
             ].
             top20 isEmpty ifTrue:[
-                |lcSelector|
-
-                lcSelector := aSelectorString asLowercase.
                 Smalltalk allMethodsWithSelectorDo:[:eachMethod :eachSelector |
                     (eachSelector asLowercase spellAgainst:lcSelector) > 50 ifTrue:[    
                         (allSelectors includes:eachSelector) ifFalse:[