@@ -1656,9 +1656,10 @@ def reprint_line(lineno, s, to_replace=[]):
16561656 self .scr .move (lineno , 4 )
16571657 map (self .echo , o .split ('\x04 ' ))
16581658
1659- y , x = self .scr .getyx ()
1659+ y = self .scr .getyx ()[0 ]
1660+ x = self .ix + len (s ) - self .cpos
16601661 if not self .cpos :
1661- x + = 1
1662+ x - = 1
16621663 if self .highlighted_paren :
16631664 # Clear previous highlighted paren
16641665 reprint_line (* self .highlighted_paren )
@@ -1690,7 +1691,15 @@ def reprint_line(lineno, s, to_replace=[]):
16901691 tokens [i ] = (Parenthesis , value )
16911692 break
16921693 elif under_cursor :
1693- tokens [i ] = (Parenthesis .UnderCursor , value )
1694+ if self .cpos :
1695+ tokens [i ] = (Parenthesis .UnderCursor , value )
1696+ else :
1697+ # The cursor is at the end of line and
1698+ # next to the paren, so it doesn't reverse
1699+ # the paren. Therefore, we insert the
1700+ # Parenthesis token here instead of the
1701+ # Parenthesis.UnderCursor token.
1702+ tokens [i ] = (Parenthesis , value )
16941703 (line , i , opening ) = opening
16951704 screen_line = y - len (self .buffer ) + line
16961705 if line == len (self .buffer ):
0 commit comments