File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 5
5
6
6
import json
7
7
import os
8
+ import re
8
9
import signal
9
10
import subprocess
10
11
import sys
@@ -266,6 +267,7 @@ def wait(self):
266
267
return rc
267
268
268
269
def _read_stdout (self ):
270
+ decode_json = True
269
271
while True :
270
272
line = self .proc .stdout .readline ()
271
273
if not line :
@@ -276,21 +278,25 @@ def _read_stdout(self):
276
278
line = line .decode ('utf-8' )
277
279
except :
278
280
self .listener .on_error (self ,
279
- 'Error decoding UTF-8: %r' % line )
281
+ '[ Error decoding UTF-8: %r] ' % line )
280
282
continue
281
- if line .startswith ('{' ):
283
+ if decode_json and line .startswith ('{' ):
282
284
try :
283
285
result = json .loads (line )
284
286
except :
285
287
self .listener .on_error (self ,
286
- 'Error loading JSON from rust:\n %r ' % line )
288
+ '[ Error loading JSON from rust: %r] ' % line )
287
289
else :
288
290
try :
289
291
self .listener .on_json (self , result )
290
292
except :
291
293
self ._cleanup ()
292
294
raise
293
295
else :
296
+ if re .match ('^\s*Finished' , line ):
297
+ # If using "cargo run", we don't want to capture lines
298
+ # starting with open bracket.
299
+ decode_json = False
294
300
# Sublime always uses \n internally.
295
301
line = line .replace ('\r \n ' , '\n ' )
296
302
self .listener .on_data (self , line )
You can’t perform that action at this time.
0 commit comments