rschmitt / heatseeker

A high-performance Selecta clone, written in Rust.
MIT License
214 stars 10 forks source link

Allow out of order matching #31

Open bradphelan opened 5 years ago

bradphelan commented 5 years ago

If I'm looking for a file called

10_inch_nails_spiral_type.bin

very often I might type

.binspiralnail

but hs will only match if I wrote

nailspiral.bin

I suggest allowing out of order matching by splitting groups on spaces

.bin spiral nail

and then in-order matching occurs in groups with no spacing and out of order matching can occur between groups. You would probably want to make this an option.

choices | hs --out-of-order-delimter=' '
rschmitt commented 5 years ago

I've been thinking about this for a few days now. It's an interesting idea for improving interactive queries, but it would also be complicated to implement. It's also difficult to see how to efficiently deal with a large number of tokens, since n tokens can be permuted into n! different queries.

I think we should look for a more specialized feature, such as a way to enter file extensions up-front, that would deliver 80% of the value with 20% of the work.

bradphelan commented 5 years ago

Maybe the following pseudo code

# first solve each group individually
solutions = for each group in groups:
                       yield solve(group)

# combine all the results into one list
solution = merge(solutions)

 # sort the lines by the score each line has
solution = sort(solution)