gh-119896: Fix CTRL-Z behavior in the new REPL on Windows (GH-122217)

This commit is contained in:
Dino Viehland 2024-07-30 05:03:52 -07:00 committed by GitHub
parent d27a53fc02
commit d1a1bca1f0
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,6 +21,8 @@
from __future__ import annotations
import sys
from contextlib import contextmanager
from dataclasses import dataclass, field, fields
import unicodedata
@ -52,7 +54,10 @@ def disp_str(buffer: str) -> tuple[str, list[int]]:
b: list[int] = []
s: list[str] = []
for c in buffer:
if ord(c) < 128:
if c == '\x1a':
s.append(c)
b.append(2)
elif ord(c) < 128:
s.append(c)
b.append(1)
elif unicodedata.category(c).startswith("C"):
@ -110,7 +115,7 @@ default_keymap: tuple[tuple[KeySpec, CommandName], ...] = tuple(
(r"\C-w", "unix-word-rubout"),
(r"\C-x\C-u", "upcase-region"),
(r"\C-y", "yank"),
(r"\C-z", "suspend"),
*(() if sys.platform == "win32" else ((r"\C-z", "suspend"), )),
(r"\M-b", "backward-word"),
(r"\M-c", "capitalize-word"),
(r"\M-d", "kill-word"),