l4l / yofi

yofi is a minimalistic menu for wayland
https://crates.io/crates/yofi
MIT License
361 stars 21 forks source link

Move selection back to best match if initial selection position is different #111

Open firecat53 opened 2 years ago

firecat53 commented 2 years ago

If you scroll down the selection list before you start typing, the selection position does not move back up to the best match (the first item) as I would expect when I start typing. In fact, you'll never end up with the exact match selected even if you type it exactly.

I hope I'm explaining that right.

Here I've scrolled down to 'Clocks' (the blue is the selected item)

scrolled down

Now I type 'flatseal' but it does not get selected as I would expect as soon as I type fl.

flatseal not selected

l4l commented 2 years ago

Cursor is forced to be in a range 0..<num-of-entries>. So after the number of displayed entries are reduced the cursor is decreased to maintain this invariant. And if you clear the input you may notice it doesn't point back to Clocks entry. Essentially there's no special cursor handling except arrows (and similar).

I feel current behavior more intuitive rather than resetting cursor for cases like exact match. Also it seems rofi does the same.

Though the matching sometimes looks too fuzzy then it should be. Perhaps there should be some scoring threshold for filtered entries.

l4l commented 2 years ago

Uh, yeah. I remembered why it has so weird listing. It matches name with keywords so at least for LibreOffice there should be pretty high score (it has a lot of keywords).

What do you think about additional parameter for search that actually changes matching only against the displayed name? For that particular case exact match will work as you want however typos are not "mitigated" by keywords (e.g flateasl won't find anything).

firecat53 commented 2 years ago

I think there's something else weird going on. You shouldn't need to add any extra options to Yofi.

You can see that 'Alacritty' is at the top of my application list. If I scroll (down arrow) down maybe halfway through my complete list and then start typing 'alac', alacritty isn't even shown as an option. If I only scroll down a few items it is. Yofi should find an application no matter where you are in the list. The same thing happens for VSCodium, which is towards the bottom of the list. If I don't scroll at all, Yofi finds the relevant applications perfectly. However, any significant scrolling through the list before typing seems to really mess up the results.

If you can't replicate, I'll post a screencast.

Edit: If you can, try bemenu-run and notice how it finds options regardless of where you are scrolled to in the list, even with some (not all) misspellings.