sxyazi / yazi

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

Disabling a key also disables key chords #899

Closed Allaman closed 5 months ago

Allaman commented 5 months ago

What system are you running Yazi on?

macOS

What terminal are you running Yazi in?

kitty 0.33.0

Did you try the latest code to see if this problem got fixed?

Not tried, and I'll explain why below

yazi --debug output

```sh Yazi yazi 0.2.4 (b10f2de 2024-03-09) Environment OS: macos-aarch64 (unix) Debug: false Emulator Emulator.via_env: ("xterm-kitty", "") Emulator.via_csi: Ok(Kitty) Emulator.detect: Kitty Adaptor Adaptor.matches: Kitty tmux TMUX: false Zellij ZELLIJ_SESSION_NAME: None Desktop XDG_SESSION_TYPE: None WAYLAND_DISPLAY: None DISPLAY: None Ueberzug Version: Err(Os { code: 2, kind: NotFound, message: "No such file or directory" }) WSL /proc/sys/fs/binfmt_misc/WSLInterop: false ```

Describe the bug

Sorry about the headline, I couldn't think of anything better.

I want to unbind d as trash command and bind it to dd (sorry, blame my muscle memory 😆 )

My approach is like so

# Unbind d
[[manager.prepend_keymap]]
on = [ "d" ]
run = ["dsagflasgd"]
desc = "Unbind default trash mapping"

# Use trash-cli to trash file
[[manager.prepend_keymap]]
on = [ "d", "d" ]
run = ['''
    shell --confirm 'trash-put "$@"'
''']
desc = "Move the files to the trash"

However, it does not work. I guess by mapping d to "noop" yazi ignores all following keystrokes and mappings?

Expected Behavior

Hitting dd triggers the configured run command

To Reproduce

see above toml snippet

Configuration

see above toml snippet

Anything else?

No response

sxyazi commented 5 months ago

Hi, this is the expected behavior. prepend_keymap is used to prepend items to the keymap, so the items appearing earlier have higher priority (matched first). Therefore, you can simply:

[[manager.prepend_keymap]]
on = [ "d", "d" ]
run = ['''
    shell --confirm 'trash-put "$@"'
''']
desc = "Move the files to the trash"

without the need to unbind d, as it has been covered by d => d and will never match. Let me know if it works for you!

Allaman commented 5 months ago

Hi, thank you again for your kind reply. I read the docs about precedence, but apparently, I did something wrong. Oddly, that works 😆

github-actions[bot] commented 3 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.