Skip to content

Conversation

@orpuente-MS
Copy link
Contributor

Fixes #2866

# we have VS Code Web + Jupyter support.
normalized_root = os.path.normpath(os.path.join(os.getcwd(), project_root))
self._config["projectRoot"] = "file://" + normalized_root
self._config["projectRoot"] = "file:///" + normalized_root
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My VS-Code instance was confusing the drive c: with the authority of the URI. The URI spec says that the way to specify an empty authority is by doing "file:///path"

https://datatracker.ietf.org/doc/html/rfc8089#appendix-B

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems odd in that on Mac and Linux the path will already start with a forward-slash. Having the extra slash may be benign, but also isn't correct.

// Rust expects paths, not encoded URIs, so we need to decode here.
// We need to decode the components and then the URI.
decodeURI(
decodeURIComponent(Utils.joinPath(uriToQuery, name).toString()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there risks here when not working with file system paths (e.g. when we load files from github, or in the web experience)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just solving the same problem you already had to do recently for the # char @minestarks ? This look safe to you?

const mappedFiles: [string, vscode.FileType][] = fileSearchResult.map(
([name, type]) => [Utils.joinPath(uriToQuery, name).toString(), type],
([name, type]) => [
// Rust expects paths, not encoded URIs, so we need to decode here.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust expects paths

I don't think this is right - in general, all the paths in the language service should be URIs coming directly from VS Code. Round tripping VS Code-generated Uris with with vscode.Uri.toString() and vscode.Uri.parse() should work fine without any need for decoding

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

Successfully merging this pull request may close these issues.

[Language Service] Project paths when calling qsharp.init() in notebooks are invalid on Windows

4 participants