@@ -1502,39 +1502,39 @@ def reprint_line(lineno, s, to_replace=[]):
15021502 pos += len (value )
15031503 under_cursor = (line == len (self .buffer ) and pos == x )
15041504 if token is Token .Punctuation :
1505- if value == '(' :
1505+ if value in '({[ ' :
15061506 if under_cursor :
1507- tokens [i ] = (Parenthesis , '(' )
1507+ tokens [i ] = (Parenthesis , value )
15081508 # Push marker on the stack
15091509 stack .append (Parenthesis )
15101510 else :
1511- stack .append ((line , i ))
1512- elif value == ')' :
1511+ stack .append ((line , i , value ))
1512+ elif value in ')}] ' :
15131513 try :
1514- value = stack .pop ()
1514+ opening = stack .pop ()
15151515 except IndexError :
15161516 # SyntaxError.. more closed parentheses than
15171517 # opened
15181518 break
1519- if value is Parenthesis :
1519+ if opening is Parenthesis :
15201520 # Marker found
1521- tokens [i ] = (Parenthesis , ')' )
1521+ tokens [i ] = (Parenthesis , value )
15221522 break
15231523 elif under_cursor :
1524- tokens [i ] = (Parenthesis , ')' )
1525- (line , i ) = value
1524+ tokens [i ] = (Parenthesis , value )
1525+ (line , i , opening ) = opening
15261526 screen_line = y - len (self .buffer ) + line
15271527 if line == len (self .buffer ):
15281528 self .highlighted_paren = (screen_line , s )
1529- tokens [i ] = (Parenthesis , '(' )
1529+ tokens [i ] = (Parenthesis , opening )
15301530 else :
15311531 self .highlighted_paren = (screen_line ,
15321532 self .buffer [line ])
15331533 # We need to redraw a line
15341534 reprint_line (
15351535 screen_line ,
15361536 self .buffer [line ],
1537- [(i , (Parenthesis , '(' ))]
1537+ [(i , (Parenthesis , opening ))]
15381538 )
15391539 elif under_cursor :
15401540 break
0 commit comments