X Tutup
Skip to content

Commit 0a97d94

Browse files
committed
Fix paren highlighting of wrapped lines.
1 parent 7020939 commit 0a97d94

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

bpython/cli.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,14 +1716,15 @@ def reprint_line(lineno, s, to_replace=[]):
17161716
self.scr.move(lineno, 4)
17171717
map(self.echo, o.split('\x04'))
17181718

1719-
y = self.scr.getyx()[0]
1719+
max_x = self.scr.getmaxyx()[1]
1720+
y = self.iy + (len(s) // max_x)
17201721
x = self.ix + len(s) - self.cpos
17211722
if not self.cpos:
17221723
x -= 1
1723-
max_x = self.scr.getmaxyx()[1]
17241724
if self.highlighted_paren:
17251725
# Clear previous highlighted paren
1726-
reprint_line(*self.highlighted_paren)
1726+
if self.highlighted_paren[0] < self.iy:
1727+
reprint_line(*self.highlighted_paren)
17271728
self.highlighted_paren = None
17281729
stack = list()
17291730
source = '\n'.join(self.buffer) + '\n%s' % (s, )
@@ -1734,8 +1735,9 @@ def reprint_line(lineno, s, to_replace=[]):
17341735
parens = dict(zip('{([', '})]'))
17351736
for (token, value) in all_tokens:
17361737
pos += len(value)
1737-
if real_pos + len(value) > max_x:
1738-
real_line += (real_pos + len(value)) // max_x
1738+
real_pos += len(value)
1739+
if real_pos > max_x:
1740+
real_line += real_pos // max_x
17391741
real_pos %= max_x
17401742
under_cursor = (line == len(self.buffer) and pos == x)
17411743
if token is Token.Punctuation:
@@ -1745,7 +1747,7 @@ def reprint_line(lineno, s, to_replace=[]):
17451747
# Push marker on the stack
17461748
stack.append((Parenthesis, value))
17471749
else:
1748-
stack.append((real_line, i, value))
1750+
stack.append((line, i, value))
17491751
elif value in parens.itervalues():
17501752
saved_stack = list(stack)
17511753
try:

0 commit comments

Comments
 (0)
X Tutup