Skip to content

"VS Code.exe" does not recognize "&" symbol in file/folder names and crops the name #899

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

Closed
yilmazdurmaz opened this issue Nov 1, 2020 · 10 comments

Comments

@yilmazdurmaz
Copy link

I recently started to work with python and found this by accidentally as I was trying to open current folder I am in.

I have a "python&sql" folder and tried to open while in terminal. since "vscode ." does not work (as in #898), I tried using "vscode %cd%" and in return got this error message:

'sql' is not recognized as an internal or external command, operable program or batch file.

took me a while to see the problem. changing the folder name as "python-sql", the command successfully opened the folder in VS Code.

Please take a look and fix.

version: WPy64-3830

@stonebig
Copy link
Contributor

stonebig commented Nov 2, 2020

Could you try with vscode "%cd%" ?

@stonebig
Copy link
Contributor

stonebig commented Nov 7, 2020

looking further, I don't see any solution with that because of DOS. and PowerShell is not an option authorized per default on Windows.

@stonebig stonebig closed this as completed Nov 7, 2020
@yilmazdurmaz
Copy link
Author

@stonebig, I don't understand why you closed it!?

I just found out that the problem is not only with folder names, but also exist for file names too.

I have my usual VSCode installation in the path as code.exe, and the one came with WinPython renamed as vscode.exe.

trying to open a file ,code "try&see.py" opens the file with correct name but vscode "try&see.py" crops the name to "try" and ignores the rest of it. "

I tried on "cmd", "powershell" and even on "bash" from git installation. all the same: names after "&" are cropped.

@stonebig
Copy link
Contributor

stonebig commented Nov 7, 2020

hum,

Can you try to modify \WPy64-3830\scripts\Noshell.vbs like this:

'from http://superuser.com/questions/140047/how-to-run-a-batch-file-without-launching-a-command-window/390129
If WScript.Arguments.Count >= 1 Then
    ReDim arr(WScript.Arguments.Count-1)
    For i = 0 To WScript.Arguments.Count-1
        Arg = WScript.Arguments(i)
        If InStr(Arg, " ") > 0 or InStr(Arg, "&") > 0 Then Arg = chr(34) & Arg & chr(34)
      arr(i) = Arg
    Next

    RunCmd = Join(arr)
    CreateObject("Wscript.Shell").Run RunCmd, 0 , True
End If

that is a oneline change:

        If InStr(Arg, " ") > 0 or InStr(Arg, "&") > 0 Then Arg = chr(34) & Arg & chr(34)

instead of

        If InStr(Arg, " ") > 0   Then Arg = chr(34) & Arg & chr(34)

@yilmazdurmaz
Copy link
Author

nope, still the same @stonebig

@stonebig
Copy link
Contributor

stonebig commented Nov 7, 2020

it works on mine:

WPy64-3860>"vs code.exe" "see&pray.py"

image

@stonebig
Copy link
Contributor

stonebig commented Nov 7, 2020

I called the icon, maybe you called something else ?

@yilmazdurmaz
Copy link
Author

my bad, I keep an older v3760 and I changed this file in its folder 👍

used the edit on v3830 and it is working.

@stonebig
Copy link
Contributor

stonebig commented Nov 7, 2020

aaaaah. will patch next release accordingly.

@yilmazdurmaz
Copy link
Author

any luck you have time for #898, might be solved in a similar scripting manner I hope.

and thanks for the help.

@yilmazdurmaz yilmazdurmaz changed the title "VS Code.exe" does not recognize "&" symbol in folder names and crops the name "VS Code.exe" does not recognize "&" symbol in file/folder names and crops the name Nov 7, 2020
stonebig added a commit to stonebig/winpython that referenced this issue Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants