yazi-rs / plugins

Place code snippets from docs into this monorepo, so that users can update more easily via package manager.
99 stars 9 forks source link

The `diff` plugin sometimes not copy the content to system clipboard #30

Open TobisLee opened 2 days ago

TobisLee commented 2 days ago

What system are you running Yazi on?

Linux Wayland

What terminal are you running Yazi in?

foot 1.19.0

yazi --debug output

Yazi
    Version: 0.3.3 (5eabd7d8 2024-10-28)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.3.3 (5eabd7d8 2024-10-28)

Emulator
    Emulator.via_env: ("foot", "")
    Emulator.via_csi: Ok(Foot)
    Emulator.detect : Foot

Adapter
    Adapter.matches: Sixel

Desktop
    XDG_SESSION_TYPE           : Some("wayland")
    WAYLAND_DISPLAY            : Some("wayland-0")
    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/fish")
    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-create: Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block-rename: Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : tmux 3.5a
    tmux build flags   : enable-sixel=Unknown
    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/tlss/.local/state/yazi" directory.

Describe the bug

The diff plugin sometimes doesn't copy the content to system clipboard but yazi shows the copy to clipboard message.

I use Ctrl+f instead Ctrl+d 屏幕录像_20241030_011013.webm

Minimal reproducer

  1. open yazi
  2. select two files
  3. use diff shortcut to copy content
  4. quit yazi
  5. see if content was copied to clipboard

Anything else?

No response

sxyazi commented 2 days ago

Have you installed xclip / wl-clipboard / xsel? https://yazi-rs.github.io/docs/installation

TobisLee commented 2 days ago

Yeah, I have installed wl-clipboard

image

sxyazi commented 2 days ago

That's weird, I can't reproduce it, could you debug it a bit please, ex calling ya.clipboard() in a plugin to see if it works along. This is the impl code of ya.clipboard():

https://github.com/sxyazi/yazi/blob/81b8c89ec15f4a1c5e5aa7450e994c3d23ee8597/yazi-plugin/src/utils/text.rs#L52-L62

TobisLee commented 1 day ago

I tested the ya.clipboard() in my plugin with or without ya.notify() function, but both work fine.

After I add the sleep function to the end of the diff plugin, I feel this bug appears more frequently. But it still not a 100% reproduce way.

        ya.clipboard(output.stdout)
        info("Diff copied to clipboard")
        ya.sleep(0.5)
sxyazi commented 1 day ago

Still can't reproduce with the ya.sleep(), I guess it may be a wl-copy problem, did you try calling it from your terminal to see if it's working?

TobisLee commented 1 day ago

I tested with wl-copy, it works fine. Can you be more specific?

image

sxyazi commented 1 day ago

I don't have a Wayland handy for testing.

If possible, it'd be best to debug it in Rust to see what's going on

TobisLee commented 1 day ago

Okay, I will debug it in weekend.