Nice little hack for Search items

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Nice little hack for Search items

Tim M
Guys -

I'm doing a little update for Intelli-Dolphin (fixing some of the bugs reported
here and adding things like - Alt-Backspace to go back in history of current
browser, and Ctrl-Shift-T for a quick refactoring menu popup).

Anyway on my todo list was to fix the way that Ctrl-Shift-F works. Typing
method names isn't so bad, but I don't like how when I type class names it
shows all the methods in the classes too (and I also don't like how wildcards
don't work either).

Anyway the following is my workaround for Intelli - but I thought I would
share it before I release as I recall others agreeing with me that they didn't
like the default behavior either.

Interestingly I found that I didn't need to support wildcards, I simply use
"contains" semantics, and the Scintilla widget (I think thats what its using)
seems to always hilite what I'm thinking of finding (which is neat)...


Simply replace the method:  #searchItemsStartingWith:maxItems:

with this:

        | result |
        aString first isLowerCase
                ifTrue:
                        [| matchingSymbols |
                        matchingSymbols := self selectorsStartingWith: aString maxItems: anInteger.
                        ^matchingSymbols collect: [:each | each displayString]].

        result := OrderedCollection new.
        environment classes do:
                        [:eachClass |
                        (eachClass name findString: aString) > 0 ifTrue: [ result add: eachClass
name]].
                       
        Package manager packageNames do: [:each |
                (each findString: aString)  > 0 ifTrue: [ result add: each]].

        ^result


Tim

p.s. Will probably release intelli in a few days - just wanted to get my
continous build working so I can automate some of the testing


Reply | Threaded
Open this post in threaded view
|

Re: Nice little hack for Search items

Tim M
Tim M wrote:

> Guys -
>.....
> Anyway on my todo list was to fix the way that Ctrl-Shift-F works. Typing
> Interestingly I found that I didn't need to support wildcards, I simply use
> "contains" semantics, and the Scintilla widget (I think thats what its using)
> seems to always hilite what I'm thinking of finding (which is neat)...


Actually its a bit more complicated if you like that automatch
facility. Scintilla is doing its binary chop based on the characters
you type in starting at the beginning of the text. so a quick fix is
also the following (which Intelli will apply):

showCompletionListAt: posInteger maxItems: maxInteger
        | prefix start choices |
        start := self tokenStartAt: posInteger.
        start = 0 ifTrue: [^self].
        prefix := view plainTextFrom: start to: posInteger.
        prefix size < 2 ifTrue: [^self].
        choices := self searchItemsStartingWith: prefix maxItems: maxInteger.
        self showCompletionList: choices prefixLength: ((choices anySatisfy:
[:each | each beginsWith: prefix]) ifTrue: [prefix size] ifFalse: [0])

onAutoComplete: aString startingAt: anInteger accept: aValueHolder
        "Private - "

        self
                insertCompletion: aString
                at: 1.
        aValueHolder value: false


The last patch is a bit odd - as I was expecting the 0 prefixLength
specified above to propogate back on the completion but it doesn't seem
to? Anyway as the widget is always expecting to search from the
beginning, you can hardcode a 1 for the onCompletion (and I'm not sure
why there is all kinds of funcky text replacing going on anyway?)

Tim