@@ -10,7 +10,7 @@ import {
1010import { PythonProject } from '../../api' ;
1111import { DEFAULT_ENV_MANAGER_ID , DEFAULT_PACKAGE_MANAGER_ID } from '../../common/constants' ;
1212import { traceError , traceInfo } from '../../common/logging' ;
13- import { getWorkspaceFile } from '../../common/workspace.apis' ;
13+ import { getWorkspaceFile , getWorkspaceFolders } from '../../common/workspace.apis' ;
1414import { PythonProjectManager , PythonProjectSettings } from '../../internal.api' ;
1515
1616function getSettings (
@@ -284,6 +284,7 @@ export interface EditProjectSettings {
284284 project : PythonProject ;
285285 envManager ?: string ;
286286 packageManager ?: string ;
287+ workspace ?: string ;
287288}
288289
289290export async function addPythonProjectSetting ( edits : EditProjectSettings [ ] ) : Promise < void > {
@@ -306,13 +307,23 @@ export async function addPythonProjectSetting(edits: EditProjectSettings[]): Pro
306307 traceError ( `Unable to find workspace for ${ e . project . uri . fsPath } ` ) ;
307308 } ) ;
308309
310+ const isMultiroot = ( getWorkspaceFolders ( ) ?? [ ] ) . length > 1 ;
311+
309312 const promises : Thenable < void > [ ] = [ ] ;
310313 workspaces . forEach ( ( es , w ) => {
311314 const config = workspace . getConfiguration ( 'python-envs' , w . uri ) ;
312315 const overrides = config . get < PythonProjectSettings [ ] > ( 'pythonProjects' , [ ] ) ;
313316 es . forEach ( ( e ) => {
317+ if ( isMultiroot ) {
318+ }
314319 const pwPath = path . normalize ( e . project . uri . fsPath ) ;
315- const index = overrides . findIndex ( ( s ) => path . resolve ( w . uri . fsPath , s . path ) === pwPath ) ;
320+ const index = overrides . findIndex ( ( s ) => {
321+ if ( s . workspace ) {
322+ // If the workspace is set, check workspace and path in existing overrides
323+ return s . workspace === w . name && path . resolve ( w . uri . fsPath , s . path ) === pwPath ;
324+ }
325+ return path . resolve ( w . uri . fsPath , s . path ) === pwPath ;
326+ } ) ;
316327 if ( index >= 0 ) {
317328 overrides [ index ] . envManager = e . envManager ?? envManager ;
318329 overrides [ index ] . packageManager = e . packageManager ?? pkgManager ;
@@ -321,6 +332,7 @@ export async function addPythonProjectSetting(edits: EditProjectSettings[]): Pro
321332 path : path . relative ( w . uri . fsPath , pwPath ) . replace ( / \\ / g, '/' ) ,
322333 envManager,
323334 packageManager : pkgManager ,
335+ workspace : isMultiroot ? w . name : undefined ,
324336 } ) ;
325337 }
326338 } ) ;
0 commit comments