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

Select current file in file picker #4905

Closed

Conversation

mangas
Copy link
Contributor

@mangas mangas commented Nov 26, 2022

An attempt at implementing #3014

@mangas mangas marked this pull request as draft November 26, 2022 21:56
@mangas mangas changed the title auto select current file in picker WIP: auto select current file in picker Nov 26, 2022
@mangas mangas force-pushed the select-current-file-picker branch 4 times, most recently from 3c042b9 to 4785866 Compare November 27, 2022 00:07
@mangas mangas changed the title WIP: auto select current file in picker Select current file in file picker Nov 27, 2022
@mangas mangas marked this pull request as ready for review November 27, 2022 00:24
@kirawi kirawi added A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer. labels Nov 27, 2022
@mangas mangas force-pushed the select-current-file-picker branch 3 times, most recently from 90bc020 to 91a6331 Compare November 29, 2022 19:48
@mangas mangas force-pushed the select-current-file-picker branch 3 times, most recently from 42ff822 to a6f87c3 Compare December 10, 2022 11:19
Copy link
Member

@dead10ck dead10ck left a comment

Choose a reason for hiding this comment

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

One minor comment, but otherwise I think this looks reasonable. It is generic enough that it allows for picking a different default in the other pickers as well in the future, should that be desirable.

I considered whether the default item member of the Picker should be a closure, rather than a concrete value, but I think in all the contexts where pickers are made, they should be able to decide at the time of that picker's construction which actual concrete value to choose as the default.

I haven't tested this locally yet, but the code seems good.

@@ -112,9 +112,11 @@ impl<T: Item> FilePicker<T> {
editor_data: T::Data,
callback_fn: impl Fn(&mut Context, &T, Action) + 'static,
preview_fn: impl Fn(&Editor, &T) -> Option<FileLocation> + 'static,
initial_cursor: Option<T>,
Copy link
Member

Choose a reason for hiding this comment

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

Should this be called initial_item instead?

@pascalkuthe
Copy link
Member

closing this PR as stale. Ultimaetly I don't think this is the direction we would be going with the picker. Sorting is not possible anymore with a streaming picker and imo this usecase is better covered by <space>F or something like #361

Thank you for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements 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