Skip to content

Commit 3310325

Browse files
Fix bpython#468 and bpython#472 highlight paren bug
1 parent 2b479b4 commit 3310325

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

bpython/repl.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,10 +933,12 @@ def tokenize(self, s, newline=False):
933933
- reads self.cpos to see what parens should be highlighted
934934
- reads self.buffer to see what came before the passed in line
935935
- sets self.highlighted_paren to (buffer_lineno, tokens_for_that_line)
936-
for buffer line that should replace that line to unhighlight it
936+
for buffer line that should replace that line to unhighlight it,
937+
or None if no paren is currently highlighted
937938
- calls reprint_line with a buffer's line's tokens and the buffer
938-
lineno that has changed iff that line is the not the current line
939+
lineno that has changed if line other than the current line changes
939940
"""
941+
highlighted_paren = None
940942

941943
source = '\n'.join(self.buffer + [s])
942944
cursor = len(source) - self.cpos
@@ -1007,16 +1009,17 @@ def tokenize(self, s, newline=False):
10071009
line_tokens[-1] = (Parenthesis, value)
10081010
(lineno, i, tokens, opening) = opening
10091011
if lineno == len(self.buffer):
1010-
self.highlighted_paren = (lineno, saved_tokens)
1012+
highlighted_paren = (lineno, saved_tokens)
10111013
line_tokens[i] = (Parenthesis, opening)
10121014
else:
1013-
self.highlighted_paren = (lineno, list(tokens))
1015+
highlighted_paren = (lineno, list(tokens))
10141016
# We need to redraw a line
10151017
tokens[i] = (Parenthesis, opening)
10161018
self.reprint_line(lineno, tokens)
10171019
search_for_paren = False
10181020
elif under_cursor:
10191021
search_for_paren = False
1022+
self.highlighted_paren = highlighted_paren
10201023
if line != len(self.buffer):
10211024
return list()
10221025
return line_tokens

0 commit comments

Comments
 (0)