Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/pip/qsharp/_qsharp.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import os
import sys
import types
from pathlib import Path
from time import monotonic
from dataclasses import make_dataclass

Expand Down Expand Up @@ -160,8 +161,7 @@ def __init__(
# For now, we only support local project roots, so use a file schema in the URI.
# In the future, we may support other schemes, such as github, if/when
# 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"] = Path(os.getcwd(), project_root).as_uri()

def __repr__(self) -> str:
return "Q# initialized with configuration: " + str(self._config)
Expand Down
11 changes: 10 additions & 1 deletion source/vscode/src/language-service/notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,16 @@ function getQSharpConfigMetadata(notebook: vscode.NotebookDocument): object {
if (data) {
const dataString = new TextDecoder().decode(data);
log.trace("found Q# config metadata: " + dataString);
return JSON.parse(dataString);
const dataStringJSON = JSON.parse(dataString);
// Re-normalize projectRoot URI if present.
// Python and VS Code have different URI normalization logic,
// so we need to parse and re-serialize it here.
if (typeof dataStringJSON.projectRoot === "string") {
const projectRootUri = vscode.Uri.parse(dataStringJSON.projectRoot, true);
dataStringJSON.projectRoot = projectRootUri.toString();
}

return dataStringJSON;
} else {
// Default to Unrestricted profile for notebooks when no explicit configuration is provided
// This aligns with the Python qsharp runtime behavior
Expand Down
Loading