@@ -6,6 +6,7 @@ import * as child_process from 'child_process';
6
6
import * as vscode from 'vscode' ;
7
7
import * as path from 'path' ;
8
8
import * as settings from './../common/configSettings' ;
9
+ import * as logger from './../common/logger' ;
9
10
10
11
var proc : child_process . ChildProcess ;
11
12
var pythonSettings = new settings . PythonSettings ( ) ;
@@ -163,12 +164,13 @@ function killProcess() {
163
164
}
164
165
165
166
function handleError ( source : string , errorMessage : string ) {
166
- console . error ( `Error (${ source } ) ${ errorMessage } ` ) ;
167
+ logger . error ( source + ' jediProxy' , `Error (${ source } ) ${ errorMessage } ` ) ;
167
168
vscode . window . showErrorMessage ( `There was an error in the python extension. Error ${ errorMessage } ` ) ;
168
169
}
169
170
170
171
function spawnProcess ( dir : string ) {
171
172
try {
173
+ logger . log ( 'child_process.spawn in jediProxy' , 'Value of pythonSettings.pythonPath is :' + pythonSettings . pythonPath ) ;
172
174
proc = child_process . spawn ( pythonSettings . pythonPath , [ "-u" , "completion.py" ] , {
173
175
cwd : dir
174
176
} ) ;
@@ -180,20 +182,23 @@ function spawnProcess(dir: string) {
180
182
handleError ( "stderr" , data ) ;
181
183
} ) ;
182
184
proc . on ( "end" , ( end ) => {
183
- console . error ( "End - " + end ) ;
185
+ logger . error ( 'spawnProcess.end' , "End - " + end ) ;
184
186
} ) ;
185
187
proc . on ( "error" , error => {
186
188
handleError ( "error" , error ) ;
187
189
} ) ;
188
190
189
191
proc . stdout . on ( "data" , ( data ) => {
192
+ //Possible there was an exception in parsing the data returned
193
+ //So append the data then parse it
190
194
var dataStr = previousData = previousData + data + ""
191
195
var responses : any [ ] ;
192
196
try {
193
197
responses = dataStr . split ( "\n" ) . filter ( line => line . length > 0 ) . map ( resp => JSON . parse ( resp ) ) ;
194
198
previousData = "" ;
195
199
}
196
200
catch ( ex ) {
201
+ //Possible we've only received part of the data, hence don't clear previousData
197
202
handleError ( "stdout" , ex . message ) ;
198
203
return ;
199
204
}
0 commit comments