File tree Expand file tree Collapse file tree 1 file changed +38
-6
lines changed
Expand file tree Collapse file tree 1 file changed +38
-6
lines changed Original file line number Diff line number Diff line change @@ -31,14 +31,46 @@ class PythonLanguageClient extends AutoLanguageClient {
3131 async startServerProcess ( projectPath ) {
3232 await new Promise ( resolve => atom . whenShellEnvironmentLoaded ( resolve ) ) ;
3333
34- var venvPromise = new Directory ( projectPath ) . getSubdirectory ( 'bin' )
35- . getFile ( 'python' )
36- . exists ( ) ;
34+ const entries = await new Promise ( resolve =>
35+ new Directory ( projectPath ) . getEntries ( ( error , entries ) => {
36+ if ( error === null ) {
37+ resolve ( entries ) ;
38+ } else {
39+ resolve ( null ) ;
40+ }
41+ } )
42+ ) ;
43+
44+ let venvPath = null ;
45+
46+ if ( entries ) {
47+ for ( let entry of entries ) {
48+ if ( entry . isDirectory ( ) ) {
49+ if (
50+ entry . getBaseName ( ) === "bin" &&
51+ ( await entry . getFile ( "python" ) . exists ( ) )
52+ ) {
53+ venvPath = projectPath ;
54+ break ;
55+ } else {
56+ if (
57+ await entry
58+ . getSubdirectory ( "bin" )
59+ . getFile ( "python" )
60+ . exists ( )
61+ ) {
62+ venvPath = entry . getPath ( ) ;
63+ break ;
64+ }
65+ }
66+ }
67+ }
68+ }
3769
38- var pylsEnvironment = Object . assign ( { } , process . env ) ;
70+ const pylsEnvironment = Object . assign ( { } , process . env ) ;
3971
40- if ( await venvPromise ) {
41- pylsEnvironment [ ' VIRTUAL_ENV' ] = projectPath ;
72+ if ( venvPath ) {
73+ pylsEnvironment [ " VIRTUAL_ENV" ] = venvPath ;
4274 }
4375
4476 const childProcess = cp . spawn ( atom . config . get ( "ide-python.pylsPath" ) , {
You can’t perform that action at this time.
0 commit comments