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

(os error 123) with :cd to name containing quotes #5921

Open
goyalyashpal opened this issue Feb 11, 2023 · 2 comments
Open

(os error 123) with :cd to name containing quotes #5921

goyalyashpal opened this issue Feb 11, 2023 · 2 comments
Labels
C-bug Category: This is a bug O-windows Operating system: Windows

Comments

@goyalyashpal
Copy link
Contributor

goyalyashpal commented Feb 11, 2023

Summary

  • When the subdirectory (or a file too?) contianing a space is tab selected in helix's command line
  • only that subdirs name is enclosed in quotes (this is also standard behaviour in bash too)

i suspect that this (quotes in middle of name) is what causes the error
but since, those quotes were put by helix itself, this is bug.

This same error is raised when the name contain any naked spaces
but that is not a bug, that's a user error as that space is inserted by user.

Originally posted by @yashpalgoyal1304 in #5882 (comment)

Reproduction Steps

I tried this:

  1. hx
  2. try typing :cd C:\Prog <tab> <ret>
    i.e. execute command :cd C:\"Program Files"
    or essentially any root folder which contains subfolders with spaces in their names.

I expected this to happen:

Current working directory is now C:\Program Files

Instead, this happened:

Couldn't change the current working directory: The filename, directory name, or volume label syntax is incorrect. (os error 123)

Helix log

~/.cache/helix/helix.log
please provide a copy of `~/.cache/helix/helix.log` here if possible, you may need to redact some of the lines
I did not file any helix directory under `%userprofile%/.cache`

Platform

Windows

Terminal Emulator

wezterm 20221119-145034-49b9839f

Helix Version

helix 22.12 (96ff64a)

@goyalyashpal goyalyashpal added the C-bug Category: This is a bug label Feb 11, 2023
@goyalyashpal
Copy link
Contributor Author

goyalyashpal commented Feb 11, 2023

this issue reduces to filepath and autocompletion handling in helix command line....

Following are some ways to solve

  • preferred imo: the command can be made to deal with in between quotations

  • better one ig: autocompletion can be made to put the whole path in quotations

  • not supporting DOS or win32 styled naked backslashes for sublevel (not ideal since copy pasting paths won't work)

    • the unix style path of forward slashes / for sublevel provides escape sequences using backward slashes \ so \ to avoid quotes

@pascalkuthe pascalkuthe added the O-windows Operating system: Windows label Feb 11, 2023
@vgwidt
Copy link

vgwidt commented Sep 11, 2023

I think either way C:\"Program Files" should be an acceptable input as that works in Windows, though "C:\Program Files" is more common. Typing out :cd "C:\Program Files" does work, typing :cd "C:\ then autocompleting results in :cd "C:\"Program Files" being typed.

I thought maybe I could get away with just adding the following to the Unqouted match in Shellwords::from to handle quotes in the middle of the word:

'"' => {
    if cfg!(windows) {
        Quoted
    } else {
        Unquoted
    }
}

It handles it as one word successfully, but then it tries to open C:\"Program Files" (actually trying to use the quotes) which doesn't exist. The behavior is the same for :open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug O-windows Operating system: Windows
Projects
None yet
Development

No branches or pull requests

3 participants