t9md / atom-lazy-motion

Rapid cursor positioning with fuzzy search.
https://atom.io/packages/lazy-motion
MIT License
20 stars 3 forks source link

Spaces? #6

Closed gilbox closed 8 years ago

gilbox commented 8 years ago

Hi, I love this plugin. I'm wondering do you ever want to jump to something with a space? For example I often want to jump to something like def show. Is there a way to do this? Maybe this is not really the intention of this plugin but it breaks my flow a little to remember that I have to use the regular cmd+f find instead of lazy-motion.

t9md commented 8 years ago

You can do by changing default configuration of lazy-motion, but it have some drawback. Read following issue for detail this is same topic.

3

gilbox commented 8 years ago

Thanks for the link. It make a lot of sense. I wish that space would match a separate token. So I guess this is a feature request, but maybe it is too complicated.

So def show would match:

But not match:

... although the letters from def show do appear in order in the phrase above, since should and now are separate tokens they should not match.


Matching non-adjacent tokens as I outlined above might be a mess. But I think it would be equally (or more) useful if it would only match adjacent tokens. So from the example above only the following two would match def show:

t9md commented 8 years ago

Did you try my isearch package? The ideas I can think from your above requirement is

I have a plan to consolidate my lazy-motion and isearch as single package. And switch search strategy based on search pattern user input like.

or simply change strategy whthere search pattern include space or not..

How do you think?

Since lazy-motion heavily depending on filtering/scoreing feature of fuzzaldrin library, I cannot and dont want to tweak lazy search algorithm itself, so switching between simple search and lazy search is what I can do.

gilbox commented 8 years ago

I tried isearch before lazy-motion and decided I liked lazy-motion better but it's been a while so I don't remember why anymore.

But I like your ideas of combining the two!

t9md commented 8 years ago

In my master branch(I still not releasing), I implemented your feature request.

Now you can specify multiple space separated search word to narrow mached result. If search pattern include white space char, it is splited then later word used to narrow former match.

Means, when you search 'def show' first, search text is split into ['def', 'show'].

  1. Search def maching tokens.
  2. Search show matching tokens from the line where def token found.
  3. Filter(=remove) show tokens where it's position is NOT greater than def token.

So when you search def show, you can find show token only which comes right position of def token.

This logic allow narrowing token by space separated search word.

lazy-motion-narrowing-by-multiple-search-word