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

Merge FilePicker into Picker #7264

Merged

Conversation

the-mikedavis
Copy link
Member

This reduces a lot of duplicated code between the Picker and FilePicker which will pave the way for larger changes to Picker necessary for #4687.

This is sudormrfbin's lovely work from #5801 merged with master and with the outstanding review feedback addressed.

Closes #5801

@the-mikedavis the-mikedavis added the S-waiting-on-review Status: Awaiting review from a maintainer. label Jun 6, 2023
pascalkuthe
pascalkuthe previously approved these changes Jun 7, 2023
Copy link
Member

@pascalkuthe pascalkuthe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for picking this up 👍

@the-mikedavis the-mikedavis added this to the next milestone Jun 16, 2023
sudormrfbin and others added 11 commits June 18, 2023 11:34
Merges the code for the Picker and FilePicker into a single Picker that
can show a file preview if a preview callback is provided. This change
was mainly made to facilitate refactoring out a simple skeleton of a
picker that does not do any filtering to be reused in a normal Picker
and a DynamicPicker (see helix-editor#5714; in particular [mikes-comment] and
[gokuls-comment]).

The crux of the issue is that a picker maintains a list of predefined
options (eg. list of files in the directory) and (re-)filters them every
time the picker prompt changes, while a dynamic picker (eg. interactive
global search, helix-editor#4687) recalculates the full list of options on every
prompt change. Using a filtering picker to drive a dynamic picker hence
does duplicate work of filtering thousands of matches for no reason. It
could also cause problems like interfering with the regex pattern in the
global search.

I tried to directly extract a PickerBase to be reused in Picker and
FilePicker and DynamicPicker, but the problem is that DynamicPicker is
actually a DynamicFilePicker (i.e. it can preview file contents) which
means we would need PickerBase, Picker, FilePicker, DynamicPicker and
DynamicFilePicker and then another way of sharing the previewing code
between a FilePicker and a DynamicFilePicker. By merging Picker and
FilePicker into Picker, we only need PickerBase, Picker and
DynamicPicker.

[gokuls-comment]: helix-editor#5714 (comment)
[mikes-comment]: helix-editor#5714 (comment)
When Picker and FilePicker are merged, not all Pickers will be able to
show a preview.

Co-authored-by: Gokul Soumya <gokulps15@gmail.com>
@the-mikedavis
Copy link
Member Author

I've recreated the commits since the conflicts are a little messy and the merge commit was glossing over a lot of changes. I also replaced the with_preview change in the original commit history.

@pascalkuthe pascalkuthe merged commit 06d63d6 into helix-editor:master Jun 19, 2023
@the-mikedavis the-mikedavis deleted the merge-picker-and-filepicker branch June 19, 2023 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants