#UI_ENHANCEMENT by cg
class: Parser
changed: #findBest:selectorsFor:in:forCompletion:
--- a/Parser.st Sun May 01 09:43:27 2016 +0200
+++ b/Parser.st Sun May 01 14:25:06 2016 +0200
@@ -820,12 +820,15 @@
"/ OLD: similarity := 100 * (1 + (lcSelector size / lcSym size)).
nCommon := (lcSelector commonPrefixWith:lcSym) size.
- nCommon > 1 ifTrue:[
+ nCommon > 0 ifTrue:[
"/ the longer the common prefix...
fractionCommon := (nCommon / lcSym size).
- "/ bump it to 100+x
- similarity := 100 * (1 + fractionCommon).
-
+ "/ bump it to 100+x if lc-prefix; to 200+x if real prefix
+ (sym startsWith:aString) ifTrue:[
+ similarity := 200 * (1 + fractionCommon).
+ ] ifFalse:[
+ similarity := 100 * (1 + fractionCommon).
+ ].
similarityRest := (lcSelector copyFrom:nCommon+1) spellAgainst:(lcSym copyFrom:nCommon+1).
similarity := similarity + similarityRest.
@@ -840,7 +843,7 @@
similarity := lcSelector spellAgainst:lcSym. "/ 0..100
].
- ((similarity > 40) or:[ (lcSelector size>1) and:[(lcSym startsWith:lcSelector)] ]) ifTrue:[
+ ((similarity > 10 "40") or:[ (lcSelector size>1) and:[(lcSym startsWith:lcSelector)] ]) ifTrue:[
(selectorsAlready includes:sym) ifFalse:[
"/ (info contains:[:entry | entry key = sym]) ifFalse:[
keepThis := true.
@@ -898,6 +901,8 @@
'select:' spellAgainst:'collect' 57
'collectWithIndex:' spellAgainst:'collect' 41
+ self findBest:20 selectorsFor:'i' in:nil forCompletion:true
+
self findBest:20 selectorsFor:'collect' in:Collection forCompletion:true
self findBest:100 selectorsFor:'collect' in:Collection forCompletion:true
@@ -905,7 +910,8 @@
self findBest:100 selectorsFor:'collect:' in:SequenceableCollection forCompletion:true
"
- "Modified: / 30-04-2016 / 13:56:40 / cg"
+ "Modified: / 01-05-2016 / 12:27:05 / cg"
+ "Modified (comment): / 01-05-2016 / 14:24:57 / cg"
!
findBestSelectorsFor:aString