@@ -22,6 +22,29 @@ let worker: Worker;
2222
2323const PYTHON_LOOKUP_TIMEOUT_MS = 2000 ;
2424
25+ function canFindSlangpyInUserSearchPaths ( ) : boolean {
26+ const configuredSearchPathsRaw = vscode . workspace . getConfiguration ( 'slang' ) . get < unknown > ( 'additionalSearchPaths' , [ ] ) ;
27+ const configuredSearchPaths = Array . isArray ( configuredSearchPathsRaw )
28+ ? configuredSearchPathsRaw
29+ . filter ( ( searchPath ) : searchPath is string => typeof searchPath === 'string' && searchPath . trim ( ) . length > 0 )
30+ . map ( ( searchPath ) => searchPath . trim ( ) )
31+ : [ ] ;
32+ const workspaceRoots = vscode . workspace . workspaceFolders ?. map ( ( folder ) => folder . uri . fsPath ) ?? [ ] ;
33+
34+ for ( const configuredPath of configuredSearchPaths ) {
35+ const candidatePaths = path . isAbsolute ( configuredPath )
36+ ? [ configuredPath ]
37+ : workspaceRoots . map ( ( workspaceRoot ) => path . resolve ( workspaceRoot , configuredPath ) ) ;
38+
39+ for ( const candidatePath of candidatePaths ) {
40+ if ( fs . existsSync ( path . join ( candidatePath , 'slangpy.slang' ) ) ) {
41+ return true ;
42+ }
43+ }
44+ }
45+ return false ;
46+ }
47+
2548async function findSlangpySearchPath ( ) : Promise < string | undefined > {
2649 let pythonInterpreterPath : string | undefined ;
2750 try {
@@ -177,7 +200,7 @@ function sendDidChangeTextDocument(event: vscode.TextDocumentChangeEvent) {
177200
178201export async function activate ( context : ExtensionContext ) {
179202 const serverModule = getSlangdLocation ( context ) ;
180- const slangpySearchPath = await findSlangpySearchPath ( ) ;
203+ const slangpySearchPath = canFindSlangpyInUserSearchPaths ( ) ? undefined : await findSlangpySearchPath ( ) ;
181204 const serverOptions : ServerOptions = {
182205 run : { command : serverModule , transport : TransportKind . stdio } ,
183206 debug : {
0 commit comments