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
Picker
s "v2"
#9647
base: master
Are you sure you want to change the base?
Picker
s "v2"
#9647
Conversation
For pickers with a single column, could we just hide the header in that case? That way it ends up looking like the original picker |
Just a couple things I noticed I haven't read trough all of it yet |
Yep actually we don't render the header if helix/helix-term/src/ui/picker.rs Lines 753 to 758 in e93685b
helix/helix-term/src/ui/picker.rs Lines 476 to 484 in e93685b
So the file picker doesn't look or behave any differently for example |
e93685b
to
827aeac
Compare
Very nice! For a slightly more compact look the column headers could be rendered with a different background - instead of having the line below. |
827aeac
to
fb63290
Compare
Yeah the separator lines were a little bulky. I removed the separators and added a theme key only for the header text |
or even move them into the separator below the input, similar to dbg mockups? |
02554fb
to
71e1d2f
Compare
That's much more complicated implementation-wise - we would probably need to change the table rendering in |
71e1d2f
to
3d78673
Compare
36a8e27
to
1dfbfe4
Compare
Wow, we have to get this on master! This solves my main issue with Helix. Brilliant work @the-mikedavis!!! |
Just started testing this. First of all, great work! One suggestion: Make debounce timeouts configurable. I have reduced them significantly (highlight: 150 -> 33 (I have a key-repeat synced to frame-rate, reason why it's so low while still debouncing effectively when scrolling), dynamic query: 275 -> 75). I have noticed flashes when using the |
What do you mean by flashes? Can you capture it in a gif / video / asciinema cast? W.r.t. configurable timeouts see #9668 (comment) |
Sure, here's an asciinema (edit: Just to confirm, since this was tested on a branch merged with all kinds of things, it also occurs on this one) |
Something I have noticed is that the global search no longer reads from the search selection. Which is a minor annoyance for something that completely replaces my use of fzf/rg. |
In the latest push I switched the query syntax to be the one mentioned at the end of #9647 (comment). So now it's |
Ah, I should have read more closely. Can confirm this works, thank you for these updates. Search is awesome now! |
ff4c76d
to
3ffd877
Compare
The original patch also contained the "contents" column (in the very first gif), can we please add that back and hide it behind default flag? I don't use the preview often and rely on the original search contents to help myself narrow down to the result. Usecase is something like jump to a function call using gw, *, global_search then use %c boolean, to search for function definition instead of other function calls |
Hmm, so I found the hidden function, I made it's constructor hidden as false and filter as true
But helix crashes... |
That panic is because @pascalkuthe and I discussed it (also see above: #9647 (comment)) and we think it'd be nice to be able to change how the preview works, so you can use the preview as it is now or alternatively show the matching line and hide the preview. That should be future work though and in the meantime I'm not interested in adding the column back to this PR since it takes up a lot of space and almost always needs to be truncated. Being able to change the preview from showing the context of the currently selected item to being the line contents of each item could be useful for other pickers in the future as well. |
Is scrolling in the picker covered in this PR or is that still an open issue? #5686 |
No this PR doesn't cover that, it's left for other PRs (I believe there is one or two open for it) |
for global search would be nice to show line number at the end of the path (much like what you get when you use |
Yes, I would like that too. I had this implemented with a separate column in the global search picker:
But for uniformity with the references picker, this would be better:
|
I think we should avoid adding an extra column for it - I don't think you would want to filter on the line number very often. We could use it in the path column so we show |
We could expand on this in the future to have different preview modes that you can toggle between with C-t. Currently that binding just hides the preview but it could switch between different preview modes and in one mode hide the path and just show the line contents.
This fixes the changed files picker when used against a clean worktree for example. Without it the running indicator does not disappear. It also simplifies the dynamic query handler's implementation so that it doesn't need to request a redraw explicitly. Co-authored-by: Pascal Kuthe <pascalkuthe@pm.me>
This introduces a custom URI type in core meant to be extended later if we want to support other schemes. For now it's just a wrapper over a PathBuf. We use this new URI type to firewall `lsp::Url`. This was previously done in 8141a4a but using a custom URI type is more flexible and will improve the way Pickers handle paths for previews in the child commit(s). Co-authored-by: soqb <cb.setho@gmail.com>
The `FileLocation` and `PathOrId` types can borrow paths rather than requiring them to be owned. This takes a refactor of the preview functions and preview internals within `Picker`. With this change we avoid an unnecessary `PathBuf` clone per render for any picker with a file preview function (i.e. most pickers). This refactor is not fully complete. The `PathOrId` is _sometimes_ an owned `PathBuf`. This is for pragmatic reasons rather than technical ones. We need a further refactor to introduce more core types like `Location` in order to eliminate the Cow and only use `&Path`s within `PathOrId`. This is left for future work as it will be a larger refactor almost entirely fitting into the LSP commands module and helix-core - i.e. mostly unrelated to refactoring the `Picker` code itself. Co-authored-by: Pascal Kuthe <pascalkuthe@pm.me>
`Picker::new` loops through the input options to inject each of them, so there's no need to collect into an intermediary Vec. This removes some unnecessary collections. Also, pickers that start with no initial options can now pass an empty slice instead of an empty Vec. Co-authored-by: Luis Useche <useche@gmail.com>
This allows us to replace any `vec![..]`s of columns where all columns are static with static slices `[..]`.
We can track the ranges in the input text that correspond to each column and use this information during rendering to apply a new theme key that makes the "active column" stand out. This makes it easier to tell at a glance which column you're entering.
3ffd877
to
e298b3c
Compare
I noticed that the column width can only grow in an active picker, due to the existing logic - // helix/helix-term/src/ui/picker.rs
if width as u16 > *max_width {
*max_width = width as u16;
} (Noticeable only in a couple of pickers with multiple columns, especially if one of them contains lengthy text.) Do you think it would be better to have default column widths (perhaps not in this PR)? I also tried resetting it to the max width of current contents instead, but the constant change in widths made it difficult to follow the results. |
The current width handling is pretty naive. I was thinking that improving it could be a follow-up. What we have now can take up a lot of space but minimizes how much the columns move around |
Small Question: On the other hand, when I am filtering/searching paths using |
Global search is not a fuzzy search its an interactive regex/grep search. It's the same as the current global search just that the results are updated as you type. |
I was hoping to make these picker changes as separate PRs but they layer in a way that makes reviewing them independently awkward: one commit changes a block and the next changes it again, so I think it's easier to review altogether. This PR is a kind of "version 2" for the
Picker
component that resolves a bunch of things we've wanted to change aboutPicker
s:DynamicPicker
s, see Workspace symbol search does not support special characters #5714)IdleTimeout
approach for syntax highlighting the preview with an event-system hook (Refactor ad-hoc hooks to use the event system #9629)DynamicPicker
forglobal_search
(interactive global search #196)DynamicPicker
rather thanIdleTimeout
. As a consequence, we can merge theDynamicPicker
type intoPicker
, a refactor that joyously removes this unfortunate block.Shout out to @pascalkuthe's excellent work with the event system (#8021) and Nucleo (#7814) that make this change possible.
The table format and filtering by columns (originally posted in #7265):
Dynamic global search running against a very large directory (originally posted in #196):
Related to #9629
Closes #196
Closes #5714
Closes #5446
Closes #3543
Closes #4956
Closes #2109