-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Refactor Picker as a table with multiple columns/filters #7265
Conversation
This is awesome! I wanted to implement this sometime too but never got around to it. I think this has a ton of potential 👍 I dont have time to review right now but it's great to see that you started on this |
Separate prompts for each field feels a little clunky. Instead I think we should have only one prompt, drop the "active column" concept, and use a lucene-like syntax for filtering by fields. For example the symbol picker could take some queries:
(The ordering in these examples shouldn't matter.) Values with spaces could be wrapped in quotes, for example Other examples:
|
I like the general idea of having a single field. The reason I suggested split columns before is that:
My idea to resolve these is the following:
A distant future idea: we could create typable command versions of the pickers that accept a prefill as an argument. This would allow binding: open function picker to a key without adding a dedicated command. It doesn't look as sleek as your variant but it should work quite well. What do you think? |
For dynamic pickers, I have some local changes that allow disabling filtering/sorting on a column. That will resolve #5714 and allow entering regexes for the global search dyn picker. I also have a change locally that allows specifying an input register for global search to set an initial query. For prefilling pickers, I think specifying a register would be a nice way to do it. I have some local changes building on #7277 that allow a sequence like I like the active column idea you describe for a priority in rendering. For matches with long lines the global search picker can get very cramped. I think there's room for improvement with truncating columns so that outlier long matches don't push the other columns out, and columns share the available space more evenly. I'd like to start with a proof-of-concept using the |
What I mean about the dynamic picker is that when you enter a string without specifying a column it wouldn't work well to fuzzy match that across all column (I would iamgine that works by ocmbining all colums into a single string that is then fuzzyatched on so you can't also modify the query that way). I think for dynamic pickers you always have to specify the column. Hence the idea to have an easy syntax for specifying queries with spaces. I think something more convenient that quotes might be nice for that but we can always bikeshed that later. Yeah for prototyping the syntax probably doesn't matter that much 👍 It should be easy to change/experiment with later. If we use column: we could indeed make that only active if such a column actually exists (removing the need for escape in most cases). That could.be a nice variant too. Using a register for prefill is nice. That syntax looks neat |
Ah yeah I see what you mean now. For the time being I have made the behavior different in dynamic pickers and regular pickers: in dynamic pickers, the "common" text (text without a field specified) automatically acts as the dynamic column's input any other fields need to be specified explicitly. It feels intuitive but I'm not sure I like having split behaviors. |
9f198da
to
71930be
Compare
When you get a chance to rebase again I'd love to test this out |
f61360f
to
8af595c
Compare
I rebased this on top of master with the nucleo changes. Kudos to @pascalkuthe: the column support in nucleo makes the changes to the fuzzy matching parts very clean! 🎉 I have reduced the scope of this PR a little so that dynamic global search is left for the future. There are a few more changes I'd like to make to this branch but I think it's nearly ready for review. |
8af595c
to
93cfbbf
Compare
Github doesn't let me link this properly (the ui is super broken) but this also addresses #3543 |
Are there any plans to move this PR forward? |
Yep, I keep this branch up to date locally and build on it for other changes (see #196 (comment)). I'm waiting on #8021 for some of the changes to global search but the table refactor could be done independently. I'll rebase this branch and clean up the commits when I get a chance. There are two small changes this branch needs too:
|
I have a branch that implements it, should I make a pr to this branch for that? I made it so if multiple columns match |
I will probably recreate this branch from scratch rather than deal with the conflicts. If you link your branch I will pick up the commit from it when I revisit this |
My branch is here, I also rebased it on master, there was just one conflict and it seems alright. EDIT: |
93cfbbf
to
fe1611a
Compare
`menu::Item` is replaced with column configurations for each picker which control how a column is displayed and whether it is passed to nucleo for filtering. (This is used for dynamic pickers so that we can filter those items with the dynamic picker callback rather than nucleo.) The picker has a new lucene-like syntax that can be used to filter the picker only on certain criteria. If a filter is not specified, the text in the prompt applies to the picker's configured "primary" column. Adding column configurations for each picker is left for the child commit.
This removes the menu::Item implementations for picker item types and adds `Vec<Column<T, D>>` configurations.
So you can select a field by a substring of its name, like `%p:syntax.rs` to specify the `path` field as "syntax.rs". Co-authored-by: ItsEthra <[email protected]>
fe1611a
to
3a8ce21
Compare
// select a column that fits key the most. | ||
field = column_names | ||
.iter() | ||
.filter(|col| col.starts_with(&text)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pascalkuthe what do you think about using fuzzy matching for this instead? It would be more forgiving, so you could use %pth:syntax.rs
for path
for example. We could even highlight the parts of the column name that matched, like we do for the parts of the query that match items
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this and fuzzy matching seems like overkill - the prefix is more straightforward. Highlighting the matching parts could also be done for prefix strings as well and would be simpler. (Could be a follow-up to #9647)
Closing in favor of #9647 which includes these commits |
The
Menu
-like portion of thePicker
is replaced with a table.Picker::new
takes a set ofColumn
s which each contain custom logic for rendering and optionally sorting and filtering an option. (Previouslyui::menu::Item
implemented that logic.) This allows filtering a picker by more than one value.Here's a small example showing changes to the symbol picker (
<space>s
) and the buffer picker (<space>b
):Here I open up the symbol picker (
<space>s
) which has two columns: symbol kind (function, enum, module, class, etc.) and name. By default the search works on the primary column which is configured as the symbol name. I can also limit the search to just%kind:field
though. The buffer picker can filter by buffer ID, modification/focus flags and path. The diagnostics pickers can filter by severity, code, message, and path (for the workspace-wide diagnostics picker).The workspace symbol picker can filter separately by symbol name, filename, and symbol kind. The symbol name is no longer passed to the fuzzy matcher which fixes some minor issues when using language-server-specific query syntaxes (see #5714). This paves the way for dynamic global search but I have left that off of this PR as the change will be large on its own.
Closes #7040
Closes #5714
Closes #5446
Closes #5110
Closes #2452
Closes #3543
There are a few TODOs: