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

cross-instance select ability? #1748

Open
3 tasks done
aidancz opened this issue Oct 9, 2024 · 8 comments
Open
3 tasks done

cross-instance select ability? #1748

aidancz opened this issue Oct 9, 2024 · 8 comments
Labels
feature New feature request

Comments

@aidancz
Copy link
Contributor

aidancz commented Oct 9, 2024

yazi --debug output

(% aidan core ~) yazi --debug 
Yazi 
    Version: 0.3.3 (Arch Linux 2024-09-05) 
    Debug  : false 
    OS     : linux-x86_64 (unix) 
Ya 
    Version: 0.3.3 (Arch Linux 2024-09-05) 
Emulator 
    Emulator.via_env: ("st-256color", "") 
    Emulator.via_csi: Ok(Unknown([])) 
    Emulator.detect : Unknown([]) 
Adapter 
    Adapter.matches: X11 
Desktop 
    XDG_SESSION_TYPE           : Some("tty") 
    WAYLAND_DISPLAY            : None 
    DISPLAY                    : Some(":0") 
    SWAYSOCK                   : None 
    HYPRLAND_INSTANCE_SIGNATURE: None 
    WAYFIRE_SOCKET             : None 
SSH 
    shared.in_ssh_connection: false 
WSL 
    WSL: false 
Variables 
    SHELL              : Some("/usr/bin/zsh") 
    EDITOR             : Some("nvim") 
    VISUAL             : Some("nvim") 
    YAZI_FILE_ONE      : None 
    YAZI_CONFIG_HOME   : None 
Text Opener 
    default: Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true }) 
    block  : Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true }) 
Multiplexers 
    TMUX               : false 
    tmux version       : tmux 3.5a 
    ZELLIJ_SESSION_NAME: None 
    Zellij version     : No such file or directory (os error 2) 
(% aidan core ~) yazi --debug 
Yazi 
    Version: 0.3.3 (Arch Linux 2024-09-05) 
    Debug  : false 
    OS     : linux-x86_64 (unix) 
Ya 
    Version: 0.3.3 (Arch Linux 2024-09-05) 
Emulator 
    Emulator.via_env: ("st-256color", "") 
    Emulator.via_csi: Ok(Unknown([])) 
    Emulator.detect : Unknown([]) 
Adapter 
    Adapter.matches: X11 
Desktop 
    XDG_SESSION_TYPE           : Some("tty") 
    WAYLAND_DISPLAY            : None 
    DISPLAY                    : Some(":0") 
    SWAYSOCK                   : None 
    HYPRLAND_INSTANCE_SIGNATURE: None 
    WAYFIRE_SOCKET             : None 
SSH 
    shared.in_ssh_connection: false 
WSL 
    WSL: false 
Variables 
    SHELL              : Some("/usr/bin/zsh") 
    EDITOR             : Some("nvim") 
    VISUAL             : Some("nvim") 
    YAZI_FILE_ONE      : None 
    YAZI_CONFIG_HOME   : None 
Text Opener 
    default: Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true }) 
    block  : Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true }) 
Multiplexers 
    TMUX               : false 
    tmux version       : tmux 3.5a 
    ZELLIJ_SESSION_NAME: None 
    Zellij version     : No such file or directory (os error 2) 
Dependencies 
    file             : 5.45 
    ueberzugpp       : 2.9.6 
    ffmpegthumbnailer: 2.2.3 
    magick           : 7.1.1-39 
    fzf              : 0.55.0 
    fd               : 10.2.0 
    rg               : 14.1.1 
    chafa            : 1.14.2 
    zoxide           : 0.9.6 
    7z               : 17.05 
    7zz              : No such file or directory (os error 2) 
    jq               : 1.7.1 
-------------------------------------------------- 
When reporting a bug, please also upload the `yazi.log` log file - only upload the most recent content by time. 
You can find it in the "/home/aidan/.local/state/yazi" directory.

Please describe the problem you're trying to solve

I want cross-instance select ability (similar to https://yazi-rs.github.io/docs/dds#session.lua but for selection)

so that I can select some files in one instance and hover another file in another instance, and run the yazi command "shell" with "$@" and "$0"

Would you be willing to contribute this feature?

  • Yes, I'll give it a shot

Describe the solution you'd like

another builtin plugin

Additional context

No response

Validations

  • I have searched the existing issues/discussions
  • The latest nightly build of Yazi doesn't already have this feature
@aidancz aidancz added the feature New feature request label Oct 9, 2024
@sxyazi
Copy link
Owner

sxyazi commented Oct 9, 2024

This is a feature that was intentionally left out during the design because I wasn’t sure how to handle the multi-tab scenario. Unlike yank, the selection is tab-specific, while yank is global.

When you have one tab open in instance A and two tabs open in instance B, after selecting a file in instance A, which tab in instance B should the file be synced to? One of them, or should both tabs be selected at the same time? If it's the latter, what’s the point of having multiple tabs?

Also, if all tabs in instance B are not sharing the same CWD as this one tab in instance A, should a selection still be made? Does this mean that sync of the tabs needs to happen before syncing the selection?

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Oct 9, 2024
@aidancz
Copy link
Contributor Author

aidancz commented Oct 9, 2024

I think selection should also be global

Different tabs or instances can be used to view different parts of the file system, thus avoiding jumping back and forth directories

I don't understand why synchronized selection would defeat the purpose of multiple tabs

Just like editing a file in an editor and then splitting the screen, the selections in different windows are synchronized, but that won't defeat the purpose of viewing different parts of the file at the same time, avoiding jumping back and forth

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Oct 9, 2024
@sxyazi
Copy link
Owner

sxyazi commented Oct 9, 2024

No, split screen and tabs are two different concepts.

For example, when you use split screen in Neovim to open the same buffer, they share the selection state, but if you open two different tabs, they won't.

Note that Yazi only has tabs and doesn't have the concept of split screens.

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Oct 9, 2024
@aidancz
Copy link
Contributor Author

aidancz commented Oct 9, 2024

I think people open different tabs or instances because they want to operate different directories at the same time. It is beneficial to avoid jumping back and forth.

For example:

yazi provides the ability to select files in different directories at the same time, such as selecting some files in directory A, then jump to directory B, and then select some files.

Providing global selection across tabs or instances makes this process convenient


Selection and operation is a continuous process. If the user selects some files, the next step must be to operate the selected files. If the user switches tabs after selecting files, then the next step must be to continue selecting or operating, not to open a new selection

Therefore, I think the selection should be global, all instances, all tabs

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Oct 9, 2024
@sxyazi
Copy link
Owner

sxyazi commented Oct 9, 2024

Selection and operation is a continuous process

Not all operations are continuous; some are discrete, and we can't overlook this part of user needs. Ignoring it would make it harder for people to do different operations, whether in the same directory or different ones, because each time they do these actions, they have to clear the global selection and re-select items when returning to a previous directory.

Making selection global would not only be a significant change but would also trigger other consequences, such as making yank unnecessary — if the selection is already global, why would we need yank? It also would make implementing dual-pane in the future impossible, among other issues. We discussed them in this FRC #319

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Oct 9, 2024
@aidancz
Copy link
Contributor Author

aidancz commented Oct 10, 2024

I have read this RFC

He means to replace the "yp" operation with "p" and the "dp" operation with "v", which saves a keystroke but goes against vim's habits. I think it is unnecessary

Making the selection global will make yank less important, but it can still be retained to be compatible with vim's operating habits

I still think that selection and operation are a continuous process. Can you give me an example where selection needs to be retained?

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Oct 10, 2024
@sxyazi
Copy link
Owner

sxyazi commented Oct 10, 2024

Can you give me an example where selection needs to be retained?

For example, we can open two tabs as different panes to achieve a dual-pane; they're just rendered in the same window. These two panes have independent selection states, and Vifm is a great example of doing this.

Also plugins based on selection states, like diff.yazi - I like to open more than one tab on startup — one for regular file operations and another for specific tasks, since their selections are independent, so there's no interference.

@aidancz
Copy link
Contributor Author

aidancz commented Oct 11, 2024

I understand.

diff.yazi does not clear the selection after execution, so it can be easily executed many times. It is good not to let other selections interfere

I thought about it. Although the need for local selection is relatively rare, it is really annoying when it is needed but not available


How about this:

  1. Add a stash state, similar to yank or cut
  2. If we stash the current selection, the selection will be cleared and stored for future use
  3. we can switch to another tab or instance, and add stashed selection
  4. we can switch to another tab or instance, and apply the stashed selection, then it changes back to selection

This will not conflict with any existing operation logic and will enhance the ability to select files. Is this feasible?


Or let the selection be global by default, and add a key to let a tab's selection switch between global and local?

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