Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.13.0b1 REPL does not travel words when pressing Ctrl+← or Ctrl+→ #119035

Closed
hroncok opened this issue May 14, 2024 · 2 comments
Closed
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@hroncok
Copy link
Contributor

hroncok commented May 14, 2024

Bug report

Bug description:

When I type this to older Python REPLs:

>>> text = "I can travel the words."

And I press Ctrl+, my cursor moves in front of w. I can press Ctrl+ again to go in front of the t etc. I can then press Ctrl+ to travel the words in the other direction. My bash behaves the same. Again, I don't know if this is Fedora's configuration of readline, or the default.

In Python 3.13.0b1 REPL, this no longer works. Pressing Ctrl+ or Ctrl+ seemingly does nothing.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

@hroncok hroncok added the type-bug An unexpected behavior, bug, or error label May 14, 2024
@Eclips4 Eclips4 added topic-repl Related to the interactive shell 3.13 bugs and security fixes 3.14 new features, bugs and security fixes labels May 14, 2024
@tomasr8
Copy link
Member

tomasr8 commented May 20, 2024

It seems that Ctrl+ is converted into ctrl left which is treated as an invalid character (same for Ctrl+). Not sure how to represent this key combination in the keymap but this dirty hack makes it work:

diff --git a/Lib/_pyrepl/input.py b/Lib/_pyrepl/input.py
index 21c24eb5cd..0b804e9252 100644
--- a/Lib/_pyrepl/input.py
+++ b/Lib/_pyrepl/input.py
@@ -61,6 +61,8 @@ def empty(self) -> bool:
 
 class KeymapTranslator(InputTranslator):
     def __init__(self, keymap, verbose=False, invalid_cls=None, character_cls=None):
         self.verbose = verbose
         from .keymap import compile_keymap, parse_keys
 
@@ -73,7 +75,14 @@ def __init__(self, keymap, verbose=False, invalid_cls=None, character_cls=None):
             d[keyseq] = command
         if self.verbose:
             print(d)
         self.k = self.ck = compile_keymap(d, ())
+        self.k['ctrl left'] = 'backward-word'
+        self.k['ctrl right'] = 'forward-word'
         self.results = deque()

@ambv
Copy link
Contributor

ambv commented May 21, 2024

See #119034 (comment) for a list of things we will be implementing as additional keyboard mappings.

ambv pushed a commit that referenced this issue May 21, 2024
@ambv ambv closed this as completed May 21, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 21, 2024
…ew repl (pythonGH-119248)

add word-skipping ctrl keybindings to new repl
(cherry picked from commit 0398d93)

Co-authored-by: Alastair Stanley <alastairstanley@ntlworld.com>
lysnikolaou pushed a commit that referenced this issue May 21, 2024
…new repl (GH-119248) (#119323)

add word-skipping ctrl keybindings to new repl
(cherry picked from commit 0398d93)

Co-authored-by: Alastair Stanley <alastairstanley@ntlworld.com>
estyxx pushed a commit to estyxx/cpython that referenced this issue Jul 17, 2024
…ew repl (python#119248)

add word-skipping ctrl keybindings to new repl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 new features, bugs and security fixes topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants