Skip to content

Commit 499dcae

Browse files
document side effects of Repl.tokenize
1 parent 8063be3 commit 499dcae

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bpython/repl.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,15 @@ def close(self):
895895
"""See the flush() method docstring."""
896896

897897
def tokenize(self, s, newline=False):
898-
"""Tokenize a line of code."""
898+
"""Tokenizes a line of code, returning pygments tokens
899+
with side effects/impurities:
900+
- reads self.cpos to see what parens should be highlighted
901+
- reads self.buffer to see what came before the passed in line
902+
- sets self.highlighted_paren to (buffer_lineno, tokens_for_that_line) for buffer line
903+
that should replace that line to unhighlight it
904+
- calls reprint_line with a buffer's line's tokens and the buffer lineno that has changed
905+
iff that line is the not the current line
906+
"""
899907

900908
source = '\n'.join(self.buffer + [s])
901909
cursor = len(source) - self.cpos

0 commit comments

Comments
 (0)