Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight arbitrary matches #808

Open
qfel opened this issue Jul 19, 2024 · 3 comments
Open

Highlight arbitrary matches #808

qfel opened this issue Jul 19, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@qfel
Copy link

qfel commented Jul 19, 2024

I'm looking into adding fuzzy history search in nushell, and one thing that it really needs is the ability to highlight the matched part of each item.

Columnar menu already supports something a bit familiar - highlighting the matched prefix via selected_match_style. But for fuzzy matching, we need to be able to highlight arbitrary parts of an item, eg.

query: oa
match: foobar

So I think this would need a new field in the Suggestion struct, describing which characters are matched.

The most straightforward/natural way for one could be:

/// An increasing list of char (not byte!) indices describing which characters from the `value` field are considered matched.
matches: Option<Vec<usize>>

Any thoughts on that? I imagine the "increasing" part can be questionable, API-wise, though makes the implementation simpler and in practice the user is likely to have it already sorted.

I'm happy to send s PR.

@qfel qfel added the enhancement New feature or request label Jul 19, 2024
@ysthakur
Copy link
Member

We're actually discussing how to do this right now, feel free to join in! #798

@qfel
Copy link
Author

qfel commented Jul 19, 2024

We're actually discussing how to do this right now, feel free to join in! #798

Ah, looked at other issues but didn't think to look over PRs. Should I close it or let it be closed once the PR is merged?

@ysthakur
Copy link
Member

You can leave this issue up. PRs may get closed, so this issue would help us know the bug wasn't fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants