python / python/cpython

REPL import tab completion moves cursor backward

Offen
#145,448 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

pending stdlib topic-repl type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Bug report

Bug description:

When tab completing ambiguous imports in the Python REPL, pressing tab once will insert the longest unambiguous completion and display "[ complete but not unique ]". Pressing tab a second time will show all the possibilities.

In Ghostty, when you press tab the second time, the cursor moves one cell to the left. This happens with cursor-style = bar as well as the default block cursor.

I reproduced this in Ghostty with both fish shell and bash. I could not reproduce this in Zed's integrated terminal (with a bar cursor) or Terminal.app (with a block cursor).

Originally posted by @injust in https://github.com/ghostty-org/ghostty/discussions/11131


I initially reported this issue to Ghostty, and the maintainer's response was:

This is a bug in Terminal.app in how it handles CUB with the cursor in the pending wrap state. Or, a bug in Python's readline in how it calculates the amount to move the cursor back. Your bug reproduces on xterm, and Ghostty matches xterm. Specifically, CUB moves exactly n cells back ignoring pending wrap in xterm and Ghostty matches this. In Terminal.app, CUB subtracts one when it is in the pending wrap state.

Since the bug reproduces in both Ghostty and xterm, it might be a bug in the Python REPL.

I captured the bug in this asciicast: https://github.com/user-attachments/files/25683940/ascii.cast.json

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs
  • gh-145727

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem Import-Vervollständigungsverhalten von readline in der Python-REPL und sieh dir die verlinkte asciicast an, um die Cursorbewegung beim zweiten Tab zu reproduzieren. Vergleiche die Cursorposition vor und nach einer mehrdeutigen Vervollständigung in einem Terminal; abgeschlossen, wenn wiederholte Tab-Vervollständigung den Cursor nicht mehr rückwärts bewegt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.