File tree Expand file tree Collapse file tree
vscode/src/language-service Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4040import os
4141import sys
4242import types
43+ from pathlib import Path
4344from time import monotonic
4445from dataclasses import make_dataclass
4546
@@ -160,8 +161,7 @@ def __init__(
160161 # For now, we only support local project roots, so use a file schema in the URI.
161162 # In the future, we may support other schemes, such as github, if/when
162163 # we have VS Code Web + Jupyter support.
163- normalized_root = os .path .normpath (os .path .join (os .getcwd (), project_root ))
164- self ._config ["projectRoot" ] = "file://" + normalized_root
164+ self ._config ["projectRoot" ] = Path (os .getcwd (), project_root ).as_uri ()
165165
166166 def __repr__ (self ) -> str :
167167 return "Q# initialized with configuration: " + str (self ._config )
Original file line number Diff line number Diff line change @@ -147,7 +147,16 @@ function getQSharpConfigMetadata(notebook: vscode.NotebookDocument): object {
147147 if ( data ) {
148148 const dataString = new TextDecoder ( ) . decode ( data ) ;
149149 log . trace ( "found Q# config metadata: " + dataString ) ;
150- return JSON . parse ( dataString ) ;
150+ const dataStringJSON = JSON . parse ( dataString ) ;
151+ // Re-normalize projectRoot URI if present.
152+ // Python and VS Code have different URI normalization logic,
153+ // so we need to parse and re-serialize it here.
154+ if ( typeof dataStringJSON . projectRoot === "string" ) {
155+ const projectRootUri = vscode . Uri . parse ( dataStringJSON . projectRoot , true ) ;
156+ dataStringJSON . projectRoot = projectRootUri . toString ( ) ;
157+ }
158+
159+ return dataStringJSON ;
151160 } else {
152161 // Default to Unrestricted profile for notebooks when no explicit configuration is provided
153162 // This aligns with the Python qsharp runtime behavior
You can’t perform that action at this time.
0 commit comments