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

find: automatically open/enter when there is one match #916

Open
1 task
ufUNnxagpM opened this issue Apr 15, 2024 · 4 comments
Open
1 task

find: automatically open/enter when there is one match #916

ufUNnxagpM opened this issue Apr 15, 2024 · 4 comments
Labels
feature New feature request

Comments

@ufUNnxagpM
Copy link

Please describe the problem you're trying to solve

Similar to the find command in ranger, if there's only a single match in the results the matched file or directory will automatically be entered/opened. This saves pressing the enter key two times.

Would you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

A new argument for find command that allows automatically executing another command, such as smart-enter, when there is one match remaining. The user is also put back into normal mode after.

The config might look something like the following

keymap = [
  { on = [ "f" ], run = ["find --smart --exec-on-single-match", "plugin --sync smart-enter"],  desc = "Find next file, and automatically enter if there's a singular match" },
]

Additional context

No response

@ufUNnxagpM ufUNnxagpM added the feature New feature request label Apr 15, 2024
@sxyazi
Copy link
Owner

sxyazi commented Apr 15, 2024

This is not feasible. find completes immediately after execution and immediately executes the plugin command following it.

It simply opens an input and does not block to wait for user input. In fact, all commands in Yazi are asynchronous, so state dependencies between such commands are not a reasonable design.

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Apr 15, 2024
@ufUNnxagpM
Copy link
Author

This is not feasible. find completes immediately after execution and immediately executes the plugin command following it.

It simply opens an input and does not block to wait for user input. In fact, all commands in Yazi are asynchronous, so state dependencies between such commands are not a reasonable design.

Thanks for the input. I think that's reasonable, especially if the find command only finds the next match instead of every match. I've thought of the following alternatives as well

  1. When running find and in the [input] keymap, allow use of the enter or smart-enter command like { on = [ "<Enter>" ], run = ["close", "enter"], desc = "Submit the selection" } to open the first match. This reduces the enter keypresses by 1.
  2. Add a --max-depth-1 flag to jump, specifically for fzf. This reduces the enter keypresses by 1.
  3. Implement another command ex. find_enter that will search the entire directory and auto open/navigate if there's one match. Will async be a problem with this as well? I'm also not sure if it's possible to 'interrupt' the user out of the input mode

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Apr 16, 2024
@ufUNnxagpM
Copy link
Author

This might make more sense to implement as a plugin. Going to close for now.

@sxyazi
Copy link
Owner

sxyazi commented Apr 22, 2024

Sorry for the late reply, this is a reasonable need, but I need some time to think about how to better implement it, reopening

@sxyazi sxyazi reopened this Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request
Projects
None yet
Development

No branches or pull requests

2 participants