[go: up one dir, main page]

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

Items selected in visual mode aren't count in cx.active.selected #1553

Closed
TD-Sky opened this issue Aug 25, 2024 · 1 comment
Closed

Items selected in visual mode aren't count in cx.active.selected #1553

TD-Sky opened this issue Aug 25, 2024 · 1 comment
Labels
invalid This doesn't seem right

Comments

@TD-Sky
Copy link
Contributor
TD-Sky commented Aug 25, 2024

What system are you running Yazi on?

Linux Wayland

What terminal are you running Yazi in?

wezterm

yazi --debug output

Yazi
    Version: 0.3.1 (9cf85c09 2024-08-24)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.3.1 (9cf85c09 2024-08-24)

Emulator
    Emulator.via_env: ("xterm-256color", "WezTerm")
    Emulator.via_csi: Ok(WezTerm)
    Emulator.detect : WezTerm

Adapter
    Adapter.matches: Iterm2

Desktop
    XDG_SESSION_TYPE: Some("wayland")
    WAYLAND_DISPLAY : Some("wayland-0")
    DISPLAY         : Some(":1")

SSH
    shared.in_ssh_connection: false

WSL
    /proc/sys/fs/binfmt_misc/WSLInterop: false

Variables
    SHELL              : Some("/bin/zsh")
    EDITOR             : Some("lvim")
    VISUAL             : Some("lvim")
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None

Text Opener
    default: Some(Opener { run: "$EDITOR \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block  : Some(Opener { run: "$EDITOR \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : No such file or directory (os error 2)
    ZELLIJ_SESSION_NAME: None
    Zellij version     : 0.40.1

Dependencies
    file             : 5.45
    ueberzugpp       : No such file or directory (os error 2)
    ffmpegthumbnailer: 2.2.2
    magick           : 7.1.1-36
    fzf              : 0.54.3
    fd               : 10.1.0
    rg               : 14.1.0
    chafa            : No such file or directory (os error 2)
    zoxide           : 0.9.4
    7z               : 17.05
    7zz              : No such file or directory (os error 2)
    jq               : 1.7.1


--------------------------------------------------
log is empty

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

cx.active.selected is empty when there are items selected in visual mode.

Minimal reproducer

  1. Running git clone https://github.com/TD-Sky/sudo.yazi.git ~/.config/yazi/plugins/sudo.yazi
  2. Install nushell: cargo install nu or use your favorite package manager
  3. add ya.dbg(#cx.active.selected) in ~/.config/yazi/plugins/sudo.yazi/init.lua:47`
  4. Bind a key like:
    [[manager.keymap]]
    on = ["R", "d"]
    run = "plugin sudo --args='remove'"
    desc = "sudo trash"
  5. Running yazi, selecting items in visual mode, run the command.
  6. You will see only the hovered file get removed
  7. The log will tell you #cx.active.selected equals 0

Anything else?

No response

@TD-Sky TD-Sky added the bug Something isn't working label Aug 25, 2024
@sxyazi
Copy link
Owner
sxyazi commented Aug 26, 2024

This is expected behavior. For safety reasons, the visual mode is designed as a temporary selection state because there are cases where selection failures can occur due to nested selection conflicts:

pub fn try_escape_visual(&mut self) -> bool {

} else if self.selected.add_many(&urls, same) != urls.len() {
AppProxy::notify_warn(
"Escape visual mode",
"Some files cannot be selected, due to path nesting conflict.",
);
return false;

If your plugin needs to support visual mode, simply send an escape command:

ya.manager_emit("escape", { visual = true })

Take a look at how the chmod.yazi plugin does it: https://github.com/yazi-rs/plugins/blob/main/chmod.yazi/init.lua#L14

Closing as it's expected

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Aug 26, 2024
@sxyazi sxyazi added invalid This doesn't seem right and removed bug Something isn't working labels Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants