helix-editor / nucleo

A fast and convenient fuzzy matcher library for rust
Mozilla Public License 2.0
899 stars 28 forks source link

[Feature request] Get match indices and matched letters indices #35

Closed Tyarel8 closed 9 months ago

Tyarel8 commented 11 months ago

I am creating an app like dmenu/rofi for windows using nucleo, emenu, and I have run into two main issues.

First, if there are multiple match candidates that are the same string, it would be nice to have a method on the snapshot to return the items along with the global index so I can differentiate between them in the gui, or just the indices and get the item with get_item().

Second, like with fzf-matcher, have some method to get the indices of the matched characters to highlight them in the gui.

pascalkuthe commented 9 months ago

First, if there are multiple match candidates that are the same string,

That is entirely possible, the column text does not need to match the item data. What you store in the item data and how you choose to use that for disambiguation is up to you but its quite possible.

Second, like with fzf-matcher, have some method to get the indices of the matched characters to highlight them in the GUI.

the match_indices function exists but only on the low level matcher because you will only need to compute the indices for the couple items that are actually rendered. Take a look at the helix picker implementation