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 55
66import  json 
77import  os 
8+ import  re 
89import  signal 
910import  subprocess 
1011import  sys 
@@ -266,6 +267,7 @@ def wait(self):
266267        return  rc 
267268
268269    def  _read_stdout (self ):
270+         decode_json  =  True 
269271        while  True :
270272            line  =  self .proc .stdout .readline ()
271273            if  not  line :
@@ -276,21 +278,25 @@ def _read_stdout(self):
276278                line  =  line .decode ('utf-8' )
277279            except :
278280                self .listener .on_error (self ,
279-                     'Error decoding UTF-8: %r'  %  line )
281+                     '[ Error decoding UTF-8: %r] '  %  line )
280282                continue 
281-             if  line .startswith ('{' ):
283+             if  decode_json   and   line .startswith ('{' ):
282284                try :
283285                    result  =  json .loads (line )
284286                except :
285287                    self .listener .on_error (self ,
286-                         'Error loading JSON from rust:\n %r '  %  line )
288+                         '[ Error loading JSON from rust: %r] '  %  line )
287289                else :
288290                    try :
289291                        self .listener .on_json (self , result )
290292                    except :
291293                        self ._cleanup ()
292294                        raise 
293295            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 
294300                # Sublime always uses \n internally. 
295301                line  =  line .replace ('\r \n ' , '\n ' )
296302                self .listener .on_data (self , line )
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments