[3.13] gh-119896: Fix CTRL-Z behavior in the new REPL on Windows (GH-122217) (#122451)

gh-119896: Fix CTRL-Z behavior in the new REPL on Windows (GH-122217)
(cherry picked from commit d1a1bca1f0)

Co-authored-by: Dino Viehland <dinoviehland@meta.com>
This commit is contained in:
Miss Islington (bot) 2024-07-30 21:34:22 +02:00 committed by GitHub
parent 8e96d85386
commit 7a90d94df7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 4 deletions

View file

@ -21,4 +21,5 @@ def wlen(s: str) -> int:
length = sum(str_width(i) for i in s)
# remove lengths of any escape sequences
sequence = ANSI_ESCAPE_SEQUENCE.findall(s)
return length - sum(len(i) for i in sequence)
ctrl_z_cnt = s.count('\x1a')
return length - sum(len(i) for i in sequence) + ctrl_z_cnt