gh-124927: Fix conversion issue between coordinates and position in REPL (#125001)

This commit is contained in:
FeH2 2025-03-11 05:54:49 +08:00 committed by GitHub
parent a931a8b324
commit 6ab5c4aa05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 1 deletions

View file

@ -62,7 +62,7 @@ def disp_str(buffer: str) -> tuple[str, list[int]]:
elif unicodedata.category(c).startswith("C"):
c = r"\u%04x" % ord(c)
s.append(c)
b.extend([0] * (len(c) - 1))
b.append(len(c))
else:
s.append(c)
b.append(str_width(c))
@ -577,6 +577,7 @@ class Reader:
cur_x = self.screeninfo[i][0]
while cur_x < x:
if self.screeninfo[i][1][j] == 0:
j += 1 # prevent potential future infinite loop
continue
cur_x += self.screeninfo[i][1][j]
j += 1