sxyazi / yazi

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

Can't open text file if the path contains a space #1526

Closed Tyarel8 closed 2 months ago

Tyarel8 commented 2 months ago

What system are you running Yazi on?

Windows

What terminal are you running Yazi in?

wezterm 20240203-110809-5046fc22

yazi --debug output

Yazi
    Version: 0.3.1 (0f106b5 2024-08-20)
    Debug  : false
    OS     : windows-x86_64 (windows)

Ya
    Version: 0.3.1 (0f106b5 2024-08-20)

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

Adapter
    Adapter.matches: Iterm2

Desktop
    XDG_SESSION_TYPE: None
    WAYLAND_DISPLAY : None
    DISPLAY         : None

SSH
    shared.in_ssh_connection: false

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

Variables
    SHELL              : None
    EDITOR             : Some("hx")
    VISUAL             : None
    YAZI_FILE_ONE      : Some("C:\\Users\\<user>\\scoop\\apps\\git\\2.46.0\\usr\\bin\\file.exe")
    YAZI_CONFIG_HOME   : Some("C:\\Users\\<user>\\Sync\\config\\yazi")

Text Opener
    default: Some(Opener { run: "hx \"%*\"", block: true, orphan: false, desc: "hx", for_: None, spread: true })
    block  : Some(Opener { run: "hx \"%*\"", block: true, orphan: false, desc: "hx", for_: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : program not found
    ZELLIJ_SESSION_NAME: None
    Zellij version     : program not found

Dependencies
    file             : 5.45
    ueberzugpp       : program not found
    ffmpegthumbnailer: program not found
    magick           : 7.1.1-36
    fzf              : 0.54.3
    fd               : 10.1.0
    rg               : 14.1.0
    chafa            : program not found
    zoxide           : 0.9.4
    7z               : 24.08
    7zz              : program not found
    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 "C:\\Users\\<user>\\AppData\\Roaming\\yazi\\state" directory.

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

I have helix as the opener for editing text like this:

[opener]
edit = [{ run = 'hx "%*"', block = true, for = "windows" }]

and if I try to open a text file with a space in it's path it opens a blank file in readonly mode. If I open another buffer with helix it shows in the tab that the file that yazi tried to open included the " in the name, like a b.txt" instead of a b.txt, so that probably is the issue.

Minimal reproducer

Add

[opener]
edit = [{ run = 'hx "%*"', block = true, for = "windows" }]

to yazi.toml and press o to open a text file that contains a space in it's path, like a b.txt

Anything else?

Shows file a b.txt with contents "hello world!" image After opening, the file is empty with readonly and the tab is called a b.txt" (the scratch is just so that the tab name shows) image

sxyazi commented 2 months ago

Try hx %* - %* is already the escaped file list, you don't need to escape it again

Tyarel8 commented 2 months ago

Thanks, that worked. Maybe it would be a good idea to point out the difference between %* and $@ in the example if one is escaped and the other is not, because I copied the neovim example in there.

Tyarel8 commented 2 months ago

I added a pull request to the docs with an example using %* in windows.

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