LMMS / lmms

Cross-platform music production software
https://lmms.io
GNU General Public License v2.0
7.98k stars 995 forks source link

Ignoring spaces in effect search #6324

Open Monospace-V opened 2 years ago

Monospace-V commented 2 years ago

Enhancement Summary

If one searches for "Stereo enhancer," show result "StereoEnhancer effect," and if one searches for "StereoMatrix," show result "Stereo Matrix" (by running a search alongside that ignores spaces in results/search expression). (Also, if possible, rename StereoEnhancer to "Stereo Enhancer" by putting a space in between, see Justification)

Justification

I have to consciously remember to keep myself from putting a space between "Stereo" and "Enhancer," or from typing "StereoMatrix" (one word), because both throw no results. The ability of search to ignore a space in both search listings and search box would be quite useful as a behaviour. (Additionally it'd be nice if there was a standard for naming effect plugins so there would be consistency in the results. But that's a plus.)

musikBear commented 2 years ago

Fyi LMMS token-search is smarter than most. 3 or 4 letters are mostly enough to give a list with decent overview. Instead of writing "StereoMatrix", it is enough to type "atri" and get: image Imo LMMS-token search is among the best in software, but an ignoring of whitespace would be add to this superiority so 👍

yohannd1 commented 2 years ago

We could also implement something similar to a "fuzzy matching system", like in fzf. In its essence, you can write just parts of the words you want to find and it'll still match them.

Basically, if I wanna use Calf Reverb specifically, currently I have to either type "Calf R" or type "Reverb" then click on the second option. With fuzzy matching, I can probably just type "calr" (CALf Reverb) or "cafr" (CAlF reverb) and it'll show Calf Reverb as the first result, to which I can then just press enter to select it.

For the ones mentioned in the initial post:

It might be kinda tricky to search this way at first but I think once you get the hang of it, it's much more powerful, I think.

And for whether it should be enabled by default - I'm not sure. I think it being enabled by default does affect the usual method of searching (searching entire words). For example, if you have this list:

Something
Something Else
Example plugin
Eplin
Aaaaa

and you want to search for the latter ("Eplin"). Unless you also sort the list by best-match (something fzf does with the --sort flag, I think), you're gonna have this:

Example plugin
Eplin

and "Eplin" won't be the first one.


Nonetheless, a note on implementing this: I don't think it's that hard to implement (but I'm not aware of the nuances that fzf has torwards this) - a simple version in python just for reference:

query = "cafr" # if you try this with "cave", it'll match the C* plugin too
plugins = [
    "C* Plate2x2 - Versatile plate reverb, stereo inputs",
    "Calf Reverb",
    "Calf Reverb LADSPA",
    "Calf Reverse Delay",
    "Calf Reverse Delay LADSPA",
]

def matches(plugin_name: str, query: str) -> bool:
    i = 0

    plugin_name = plugin_name.lower() # for case-insensitivity

    for query_char in query:
        while True:
            if i >= len(plugin_name):
                # We reached the end of the plugin name without reaching the end of the query! It didn't match completely, then.
                return False

            if query_char == plugin_name[i]:
                # matched! break, and then it'll go to the next char in the query
                i += 1
                break
            else:
                # didn't match; continue to the next char in the plugin name
                i += 1

    return True

print(f"Match for query {repr(query)}:")
for plugin in plugins:
    if matches(plugin, query):
        print(plugin)

For sorting matches, I'm not sure exactly how to do that... uh.

Oh, and it would be cool if a "cafe" query also matched a hypotetical "café" plugin, but I'm not sure how that could be done either (it is something fzf also does, though, so it's possible).

zonkmachine commented 5 months ago

Related issue: https://github.com/LMMS/lmms/issues/6502 (Searching effects with diacritical marks in the name).