Skip to content

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

Description

@hroncok

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

Activity

  1. added
    topic-replRelated to the interactive shell
    3.13only security fixes
    3.14bugs and security fixes
    on May 14, 2024
  2. tomasr8 commented on May 20, 2024

    @tomasr8
    Member

    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()
  3. ambv commented on May 21, 2024

    @ambv
    Contributor

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

  4. added a commit that references this issue on May 21, 2024
  5. added a commit that references this issue on May 21, 2024
  6. added a commit that references this issue on May 21, 2024
  7. added a commit that references this issue on Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixes3.14bugs and security fixestopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions