Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-145448: Fix REPL tab completion cursor position in pending wrap state#145727

Open
mvanhorn wants to merge 1 commit intopython:mainfrom
mvanhorn:osc/145448-fix-repl-tab-cursor
Open

gh-145448: Fix REPL tab completion cursor position in pending wrap state#145727
mvanhorn wants to merge 1 commit intopython:mainfrom
mvanhorn:osc/145448-fix-repl-tab-cursor

Conversation

@mvanhorn
Copy link

@mvanhornmvanhorn commentedMar 10, 2026
edited by bedevere-appbot
Loading

Fixes#145448

Summary

When the PyREPL's__write_changed_line writes to the last column of the terminal, the cursor enters "pending wrap" state - it physically stays at columnwidth-1 butposxy was recordingwidth. This caused subsequent CUB (Cursor Backward) escape sequences to overshoot by one cell, moving the cursor one position too far left.

Root cause: Inunix_console.py, three code paths in__write_changed_line setposxy to the full line width without accounting for pending wrap state. When the cursor is later moved back (e.g., to return to the input line after showing "[ complete but not unique ]"), the CUB count is calculated astarget_x - width instead oftarget_x - (width-1), producing one extra backward movement.

Fix: Capposxy[0] atself.width - 1 when writing reaches the terminal edge. This matches the physical cursor position in pending wrap state, so CUB calculations produce the correct count.

Why Terminal.app isn't affected: Terminal.app compensates by subtracting 1 from CUB in pending wrap state. xterm and Ghostty do not compensate, matching the spec more strictly.

Test plan

  • All 244test_pyrepl tests pass
  • NEWS entry added
  • Fix applied to all threeposxy assignment paths in__write_changed_line

This contribution was developed with AI assistance (Claude Code).

…rap stateWhen __write_changed_line writes to the last column of the terminal,the cursor enters "pending wrap" state where it physically stays atwidth-1. However, posxy was recording width, causing subsequent CUB(Cursor Backward) calculations to overshoot by one cell.Cap posxy x-coordinate at width-1 to match the physical cursorposition in pending wrap state. This fixes the cursor moving backwardduring tab completion in xterm and Ghostty.Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@pablogsalpablogsalAwaiting requested review from pablogsalpablogsal is a code owner

@lysnikolaoulysnikolaouAwaiting requested review from lysnikolaoulysnikolaou is a code owner

@ambvambvAwaiting requested review from ambvambv is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

REPL import tab completion moves cursor backward

1 participant

@mvanhorn

[8]ページ先頭

©2009-2026 Movatter.jp