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

vscode.workspaces[0].uri.path on windows returns a path with a forward slash in the beginning #111440

Closed
AllanOricil opened this issue Nov 28, 2020 · 5 comments
Assignees
Labels
*as-designed Described behavior is as designed

Comments

@AllanOricil
Copy link

AllanOricil commented Nov 28, 2020

vscode.workspaces[0].uri.path on windows is returning a path with a forward slash in the beginning, but this is not a valid path. Could you remove it if node is running on Windows?

image

If it can't be removed is there a probem if I use the private prop _fsPath ? I'm asking it because that one is right.

  • VSCode Version: 1.46.0 this is the package version I'm currently using
  • OS Version: Windows 10

Steps to Reproduce:

  1. Just call vscode.workspaces[0].uri.path on Windows

Does this issue occur when all extensions are disabled?: NA

@AllanOricil
Copy link
Author

I solved my problem using the getter fsPath. But I would like to understand when I should use the path attribute.

@GustavoASC
Copy link
Contributor

I had this same problem and solved it using fsPath as you said. I am also confused about when one should use path instead of fsPath...

@jrieken jrieken added the *as-designed Described behavior is as designed label Nov 30, 2020
@jrieken
Copy link
Member

jrieken commented Nov 30, 2020

The path-component of uris always uses forward slashes, when accessing the file system you can use fsPath (which takes UNC paths into account). However, it is advised to use vscode.workspace.fs to read/write files because that can be used in other contexts as well

@AllanOricil
Copy link
Author

@GustavoASC I found tests to help us understand how to use vscode.workspace.fs https://github.com/microsoft/vscode/blob/master/extensions/vscode-api-tests/src/singlefolder-tests/workspace.fs.test.ts

@github-actions github-actions bot locked and limited conversation to collaborators Jan 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

4 participants
@jrieken @GustavoASC @AllanOricil and others