@@ -28,6 +28,7 @@ import { BlockFormatProviders } from './typeFormatters/blockFormatProvider';
2828import  *  as  os  from  'os' ; 
2929import  *  as  fs  from  'fs' ; 
3030import  {  activateSingleFileDebug  }  from  './singleFileDebug' ; 
31+ import  {  getPathFromPythonCommand  }  from  './common/utils' ; 
3132
3233const  PYTHON : vscode . DocumentFilter  =  {  language : 'python' ,  scheme : 'file'  } ; 
3334let  unitTestOutChannel : vscode . OutputChannel ; 
@@ -63,9 +64,13 @@ export function activate(context: vscode.ExtensionContext) {
6364 context . subscriptions . push ( activateFormatOnSaveProvider ( PYTHON ,  settings . PythonSettings . getInstance ( ) ,  formatOutChannel ) ) ; 
6465
6566 context . subscriptions . push ( vscode . commands . registerCommand ( Commands . Start_REPL ,  ( )  =>  { 
66-  let  term  =  vscode . window . createTerminal ( 'Python' ,  pythonSettings . pythonPath ) ; 
67-  term . show ( ) ; 
68-  context . subscriptions . push ( term ) ; 
67+  getPathFromPythonCommand ( [ "-c" ,  "import sys;print(sys.executable)" ] ) . catch ( ( ) => { 
68+  return  pythonSettings . pythonPath ; 
69+  } ) . then ( pythonExecutablePath  =>  { 
70+  let  term  =  vscode . window . createTerminal ( 'Python' ,  pythonExecutablePath ) ; 
71+  term . show ( ) ; 
72+  context . subscriptions . push ( term ) ; 
73+  } ) ; 
6974 } ) ) ; 
7075
7176 // Enable indentAction 
@@ -136,7 +141,12 @@ class PythonExt {
136141
137142 private  _ensureState ( ) : void { 
138143 // context: python.isDjangoProject 
139-  this . _isDjangoProject . set ( fs . existsSync ( vscode . workspace . rootPath . concat ( "/manage.py" ) ) ) ; 
144+  if  ( typeof  vscode . workspace . rootPath  ===  'string' ) { 
145+  this . _isDjangoProject . set ( fs . existsSync ( vscode . workspace . rootPath . concat ( "/manage.py" ) ) ) ; 
146+  } 
147+  else  { 
148+  this . _isDjangoProject . set ( false ) ; 
149+  } 
140150 } 
141151} 
142152
0 commit comments