Modified arrow keys resolve to the opposite direction: ESC[1;6A is Ctrl+Shift+Up but maps to ControlShiftDown (10 entries)
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 92/100
調査の方向性
src/prompt_toolkit/input/ansi_escape_sequences.py から始め、issue に記載されたシーケンス文法と照合して、一覧にある 10 個の矢印およびチルダのエントリを調べます。PYTHONPATH=src で pytest を実行し、その後、各修飾子の A シーケンスが Up に、B シーケンスが Down に解決されることを確認するカバレッジを追加します。10 個すべてのマッピングが修正され、axis test がパスすれば完了です。
索引モデルが issue の本文から書いたものです。
説明
The bug
Ten entries in src/prompt_toolkit/input/ansi_escape_sequences.py name the wrong key.
The arrow ones are transposed in pairs, so Ctrl+Shift+Up moves the cursor down and
Ctrl+Shift+Down moves it up — in any application built on prompt_toolkit, on any terminal
that reports modified arrows.
Present on main at 583b341 (the 3.0.53 release commit).
The evidence, from the table's own entries
The table already agrees that final byte A is cursor-up and B is cursor-down at four
of the eight modifier levels it carries. It disagrees with itself at the other four:
mod ESC[1;<n>A (cursor up) ESC[1;<n>B (cursor down)
2 ShiftUp ShiftDown ok
3 (Escape, Up) (Escape, Down) ok
4 (Escape, ShiftDown) (Escape, ShiftUp) SWAPPED
5 ControlUp ControlDown ok
6 ControlShiftDown ControlShiftUp SWAPPED
7 (Escape, ControlDown) (Escape, ControlUp) SWAPPED
8 (Escape, ControlShiftDown) (Escape, ControlShiftUp) SWAPPED
9 (Escape, Up) (Escape, Down) ok
And the same shape in the tilde family, where 5~ is PageUp and 6~ is PageDown:
ESC[5;7~ Ctrl+Alt+PageUp -> (Escape, ControlPageDown) should be ControlPageUp
ESC[5;8~ Ctrl+Alt+Shift+PageUp -> (Escape, ControlShiftPageDown) should be ControlShiftPageUp
ESC[6;7~ Ctrl+Alt+PageDown -> (Escape, ControlPageDown) correct
ESC[6;8~ Ctrl+Alt+Shift+PageDown -> (Escape, ControlShiftPageDown) correct
Those two are not a swap — 5;7~ and 6;7~ resolve to the same value, so the PageUp row
looks copied from the PageDown row rather than transposed with it.
Left/Right (C/D) and Home/End (H/F) are correct at every modifier level. Only
the up/down axis is affected. That is 8 arrow entries + 2 tilde entries = 10.
Independent confirmation from a terminal
Not derived from the table. kitty 0.48.2's own encoder, asked what it sends for those
presses using its own key identities:
Ctrl+Shift+Up -> ESC[1;6A table says ControlShiftDown
Ctrl+Shift+Down -> ESC[1;6B table says ControlShiftUp
Alt+Shift+Up -> ESC[1;4A table says (Escape, ShiftDown)
Alt+Shift+Down -> ESC[1;4B table says (Escape, ShiftUp)
Ctrl+Alt+Up -> ESC[1;7A table says (Escape, ControlDown)
Ctrl+Alt+PageUp -> ESC[5;7~ table says (Escape, ControlPageDown)
This also matches xterm's ctlseqs: CSI 1 ; modifier A is cursor-up, B is cursor-down,
CSI 5 ; modifier ~ is Prior/PageUp and CSI 6 ; modifier ~ is Next/PageDown.
Reproduce
from prompt_toolkit.input.ansi_escape_sequences import ANSI_SEQUENCES
ANSI_SEQUENCES["\x1b[1;6A"] # Keys.ControlShiftDown -- Ctrl+Shift+Up
ANSI_SEQUENCES["\x1b[1;6B"] # Keys.ControlShiftUp -- Ctrl+Shift+Down
Or bind c-s-up in any prompt_toolkit application and press Ctrl+Shift+Up on a terminal
that reports modified arrows.
Why it has survived
Every row in a literal lookup table is independently unfalsifiable — a wrong row looks
exactly like a right one, and nothing cross-checks A against B. I found these by
building a parser that computes the key from the sequence's grammar rather than looking it
up, and diffing its answers against the table across the whole space. A parser cannot
disagree with itself about which final byte means up, so the disagreements surfaced on
their own; there were exactly these ten, plus two documented divergences that are not
defects.
A test that walks the axis — for each modifier, assert 1;<n>A resolves to a key whose
name contains Up and 1;<n>B to one containing Down — would have caught all ten and
would catch the next one. Happy to open a PR with the ten corrections and that test if
that shape is welcome.
Environment
prompt_toolkit main @ 583b341, verified against a clean checkout with PYTHONPATH=src
(pointing pytest at the checkout without it silently tests the installed wheel instead).
Python 3.14.7, Linux. Terminal evidence from kitty 0.48.2.
- 主要言語
- Python
- スター
- 10.6k
- フォーク
- 834
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
prompt-toolkit/python-prompt-toolkit のほかの issue
-
ANSI.format lets a C1 CSI set a color対応中かも @SashaMIT が 20 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
Add CSharp Console to PROJECTS.rst対応中かも @jw9829 が 24 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
-
Document.translate_row_col_to_index does not clamp negative rows to zero対応中かも @oodadoudou が 39 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
TelnetServer recv error: Forcing an RST request to the telnet server can cause a crash対応中かも @liyimil が 95 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
prompt-toolkit/python-prompt-toolkit#2073 · コメント 2 件 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
prompt-toolkit/python-prompt-toolkit の issue をすべて見る
似ている issue
-
Uninstall guide omits the CloudWatch log groups AWS CodeBuild creates for useCodeBuild pipelinesオープンbug documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
awslabs/visual-asset-management-system#552 ·
メンテナーはふだん 1 日以内に返信
-
netbox status: needs triage type: documentation
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
netbox-community/netbox#23460 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
awslabs/threat-composer#362 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ansys/pyansys-common-mcp#213 ·
メンテナーはふだん 3 日以内に返信