@@ -2,16 +2,16 @@ import * as ch from 'child_process';
22import * as fs from 'fs-extra' ;
33import * as path from 'path' ;
44import { PassThrough } from 'stream' ;
5- import { Disposable , ExtensionContext , LogOutputChannel , Uri , workspace } from 'vscode' ;
5+ import { Disposable , ExtensionContext , LogOutputChannel , Uri } from 'vscode' ;
66import * as rpc from 'vscode-jsonrpc/node' ;
77import { PythonProjectApi } from '../../api' ;
88import { ENVS_EXTENSION_ID , PYTHON_EXTENSION_ID } from '../../common/constants' ;
99import { getExtension } from '../../common/extension.apis' ;
10- import { traceLog , traceVerbose } from '../../common/logging' ;
10+ import { traceError , traceLog , traceVerbose , traceWarn } from '../../common/logging' ;
1111import { untildify } from '../../common/utils/pathUtils' ;
1212import { isWindows } from '../../common/utils/platformUtils' ;
1313import { createRunningWorkerPool , WorkerPool } from '../../common/utils/workerPool' ;
14- import { getConfiguration } from '../../common/workspace.apis' ;
14+ import { getConfiguration , getWorkspaceFolders } from '../../common/workspace.apis' ;
1515import { noop } from './utils' ;
1616
1717export async function getNativePythonToolsPath ( ) : Promise < string > {
@@ -387,7 +387,7 @@ function getPythonSettingAndUntildify<T>(name: string, scope?: Uri): T | undefin
387387 * Combines legacy python settings (with migration), globalSearchPaths, and workspaceSearchPaths.
388388 * @returns Array of search directory paths
389389 */
390- async function getAllExtraSearchPaths ( ) : Promise < string [ ] > {
390+ export async function getAllExtraSearchPaths ( ) : Promise < string [ ] > {
391391 const searchDirectories : string [ ] = [ ] ;
392392
393393 // Handle migration from legacy python settings to new search paths settings
@@ -401,7 +401,7 @@ async function getAllExtraSearchPaths(): Promise<string[]> {
401401 }
402402
403403 // Get globalSearchPaths
404- const globalSearchPaths = getGlobalSearchPaths ( ) ;
404+ const globalSearchPaths = getGlobalSearchPaths ( ) . filter ( ( path ) => path && path . trim ( ) !== '' ) ;
405405 searchDirectories . push ( ...globalSearchPaths ) ;
406406
407407 // Get workspaceSearchPaths
@@ -420,14 +420,14 @@ async function getAllExtraSearchPaths(): Promise<string[]> {
420420 searchDirectories . push ( trimmedPath ) ;
421421 } else {
422422 // Relative path - resolve against all workspace folders
423- const workspaceFolders = workspace . workspaceFolders ;
423+ const workspaceFolders = getWorkspaceFolders ( ) ;
424424 if ( workspaceFolders ) {
425425 for ( const workspaceFolder of workspaceFolders ) {
426426 const resolvedPath = path . resolve ( workspaceFolder . uri . fsPath , trimmedPath ) ;
427427 searchDirectories . push ( resolvedPath ) ;
428428 }
429429 } else {
430- traceLog ( 'Warning: No workspace folders found for relative path:' , trimmedPath ) ;
430+ traceWarn ( 'Warning: No workspace folders found for relative path:' , trimmedPath ) ;
431431 }
432432 }
433433 }
@@ -455,7 +455,7 @@ function getGlobalSearchPaths(): string[] {
455455 const globalPaths = inspection ?. globalValue || [ ] ;
456456 return untildifyArray ( globalPaths ) ;
457457 } catch ( error ) {
458- traceLog ( 'Error getting globalSearchPaths:' , error ) ;
458+ traceError ( 'Error getting globalSearchPaths:' , error ) ;
459459 return [ ] ;
460460 }
461461}
@@ -469,7 +469,7 @@ function getWorkspaceSearchPaths(): string[] {
469469 const inspection = envConfig . inspect < string [ ] > ( 'workspaceSearchPaths' ) ;
470470
471471 if ( inspection ?. globalValue ) {
472- traceLog (
472+ traceError (
473473 'Error: python-env.workspaceSearchPaths is set at the user/global level, but this setting can only be set at the workspace or workspace folder level.' ,
474474 ) ;
475475 }
@@ -486,7 +486,7 @@ function getWorkspaceSearchPaths(): string[] {
486486 // Default empty array (don't use global value for workspace settings)
487487 return [ ] ;
488488 } catch ( error ) {
489- traceLog ( 'Error getting workspaceSearchPaths:' , error ) ;
489+ traceError ( 'Error getting workspaceSearchPaths:' , error ) ;
490490 return [ ] ;
491491 }
492492}
@@ -561,7 +561,7 @@ async function handleLegacyPythonSettingsMigration(): Promise<boolean> {
561561
562562 return true ; // Legacy paths are now covered by globalSearchPaths
563563 } catch ( error ) {
564- traceLog ( 'Error during legacy python settings migration:' , error ) ;
564+ traceError ( 'Error during legacy python settings migration:' , error ) ;
565565 return false ; // On error, include legacy paths separately to be safe
566566 }
567567}
0 commit comments