sxyazi / yazi

💥 Blazing fast terminal file manager written in Rust, based on async I/O.
https://yazi-rs.github.io
MIT License
16.36k stars 378 forks source link

`manager_emit("open")` doesn't support multiple files #1378

Closed Zeioth closed 3 months ago

Zeioth commented 3 months ago

What system are you running Yazi on?

Linux Wayland

What terminal are you running Yazi in?

foot version: 1.17.2 +pgo +ime +graphemes -assertions

yazi --debug output

x

Did you try the latest nightly build to see if the problem got fixed?

Yes, and I updated the debug information above (yazi --debug) to the nightly that I tried

Describe the bug

The example from the website work for single files, but when more than one file is selected, pressing enter, only one file opens.

This bug is only present when using manager_emit("open"). Disabling the plugin, I can open multiple files again (but then I wouldn't have smart enter).

Expected Behavior

when multiple files are selected, manager_emit("open") open all of them.

To Reproduce

Only one file will open. Disabling the plugin solves the issue.

Configuration

No response

Anything else?

Please let me know if you need more details, I'm around.

sxyazi commented 3 months ago

That isn't a bug but intentional. The idea is to make "open" act like "enter" since "enter" only targets the currently hovered file. If you don't want it to work this way, just remove hovered = true.

Doc of open: https://yazi-rs.github.io/docs/configuration/keymap#manager.open

Zeioth commented 3 months ago

That did the trick thanks. I suggest updating the example in the tips section with hovered = false to avoid people from running into the same issue.

sxyazi commented 3 months ago

Well it used to be set to false, but I added it because some users reported accidental triggers, though your experience seems to be the opposite.

Maybe we can add a note explaining it below. Do you want to raise a PR to change it? Just click the "Edit this page" link on that page.

Zeioth commented 3 months ago

Thank you referring me! Coming from ranger, I would vote for making this plugin the default behavior. It's still possible to open entire directories with:

[manager]
keymap = [
    { on = [ "<C-Enter>" ], run = "open --interactive", desc = "Open the selected files interactively" },
]

Which is probably enough for such a border case.

sxyazi commented 3 months ago

AFAIK, Ranger doesn't support selecting files across directories, and that's the main reason I set it to true - when you've selected files in multiple directories, it's easy to accidentally trigger something by pressing l or Enter in the current directory.

github-actions[bot] commented 2 months ago

I'm going to lock this issue because it has been closed for 30 days. ⏳ This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.