File tree Expand file tree Collapse file tree 2 files changed +10
-28
lines changed
Expand file tree Collapse file tree 2 files changed +10
-28
lines changed Original file line number Diff line number Diff line change @@ -51,24 +51,9 @@ export class PythonSettings implements IPythonSettings {
5151
5252 this . initializeSettings ( ) ;
5353 }
54- private getVirtualenvPath ( ) : string {
55- var currentPath : string = vscode . workspace . rootPath ;
56- if ( process . platform == 'win32' ) {
57- var bin : string = "Scripts" ;
58- var _path : string = path . join ( currentPath , bin , "python.exe" ) ;
59- }
60- else {
61- var bin : string = "bin" ;
62- var _path : string = path . join ( currentPath , bin , "python" ) ;
63- }
64- return fs . existsSync ( _path )
65- ? _path
66- : null ;
67- }
6854 private initializeSettings ( ) {
6955 var pythonSettings = vscode . workspace . getConfiguration ( "python" ) ;
70- var virtualEnvPath = this . getVirtualenvPath ( ) ;
71- this . pythonPath = typeof virtualEnvPath === "string" ? virtualEnvPath : pythonSettings . get < string > ( "pythonPath" ) ;
56+ this . pythonPath = pythonSettings . get < string > ( "pythonPath" ) ;
7257 var lintingSettings = pythonSettings . get < ILintingSettings > ( "linting" ) ;
7358 if ( this . linting ) {
7459 Object . assign < ILintingSettings , ILintingSettings > ( this . linting , lintingSettings ) ;
Original file line number Diff line number Diff line change @@ -87,34 +87,31 @@ export class LocalDebugClient extends DebugClient {
8787 }
8888 }
8989 private getShebangLines ( program : string ) : Promise < string [ ] > {
90+ const MAX_SHEBANG_LINES = 2 ;
9091 return new Promise < string [ ] > ( ( resolve , reject ) => {
9192 var lr = new LineByLineReader ( program ) ;
92- var lineNumber = 0 ;
9393 var shebangLines : string [ ] = [ ] ;
9494
9595 lr . on ( 'error' , err => {
96- resolve ( shebangLines ) ;
96+ reject ( err ) ;
9797 } ) ;
9898 lr . on ( 'line' , ( line : string ) => {
99- lineNumber ++ ;
99+ if ( shebangLines . length >= MAX_SHEBANG_LINES ) {
100+ lr . close ( ) ;
101+ return false ;
102+ }
100103 var trimmedLine = line . trim ( ) ;
101104 if ( trimmedLine . startsWith ( "#" ) ) {
102105 shebangLines . push ( line ) ;
103106 }
104- if ( lineNumber >= 2 ) {
105- //Ensure we always have two lines, even if no shebangLines
106- //This way if ever we get lines numbers in errors for the python file, we have a consistency
107- while ( shebangLines . length <= 2 ) {
108- shebangLines . push ( "#" ) ;
109- }
110- resolve ( shebangLines ) ;
111- lr . close ( ) ;
107+ else {
108+ shebangLines . push ( "#" ) ;
112109 }
113110 } ) ;
114111 lr . on ( 'end' , function ( ) {
115112 //Ensure we always have two lines, even if no shebangLines
116113 //This way if ever we get lines numbers in errors for the python file, we have a consistency
117- while ( shebangLines . length <= 2 ) {
114+ while ( shebangLines . length < MAX_SHEBANG_LINES ) {
118115 shebangLines . push ( "#" ) ;
119116 }
120117 resolve ( shebangLines ) ;
You can’t perform that action at this time.
0 commit comments