Mapping with `<Esc>` after another key matches only the first byte of a kitty-protocol Esc
メンテナーはふだん 13 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with handle_mapping() in src/getchar.c and inspect how it calls check_termcode() when a mapping includes Escape after another key. Reproduce with the provided feedkeys() command or a kitty-protocol terminal, then trace how the remaining typeahead is handled. Done means CSI 27 u matches <Esc> in the mapping without leaving [27u behind, and plain Escape still works.
索引モデルが issue の本文から書いたものです。
説明
Steps to reproduce
- Start
vim --cleanin a terminal where Vim enables the kitty keyboard protocol. I used Ghostty, which the default 'keyprotocol' matches withghostty:kitty. :nnoremap <Leader><Esc> <Nop>- Make nine changes:
o1<Esc>,o2<Esc>, and so on througho9<Esc>. - Press
\, then<Esc>.
The mapping runs, and then the last seven changes are undone ("7 fewer lines; before #3"). I first noticed this with nnoremap <Leader><Esc> :nohlsearch<CR>.
With the kitty protocol, Esc arrives as CSI 27 u (ESC [ 2 7 u). The mapping matches \ plus only the first byte of that sequence, and [27u is left in the typeahead. [2 fails, and 7u undoes seven changes.
The same thing happens without a kitty terminal (tested with TERM=xterm-256color) if step 4 is replaced with:
:call feedkeys("\\\<Esc>[27u", "L")
The cause appears to be in handle_mapping() in src/getchar.c. check_termcode() runs only when no mapping fully matched, or when the full match is a lone ESC (mp_match_len == 1 && *mp->m_keys == ESC). A mapping where <Esc> follows another key gets no such exception, so the raw ESC byte completes the mapping before CSI 27 u is translated to <Esc>.
Workaround: set keyprotocol-=ghostty:kitty followed by let &term = &term in the vimrc.
Expected behaviour
CSI 27 u matches <Esc> in the mapping the same way a plain ESC byte does: the mapping runs and no keys are left over. When the terminal sends a plain ESC byte, the mapping works and nothing is undone.
Version of Vim
9.1.1752 (macOS system Vim). Not tested on 9.2, but the logic described above is the same in v9.2.1252.
Environment
Operating system: macOS 26.7
Terminal: Ghostty 1.4.0
Value of $TERM: xterm-ghostty
Shell: bash 5.3.20
- 主要言語
- Vim Script
- スター
- 41.4k
- フォーク
- 6.2k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
vim/vim のほかの issue
-
autoconf failes to find libsodium even when present due to implicit function declaration対応中かも @coderjoe が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 13 日以内に返信
-
`json_decode()` uses a number as a string pointer when 'encoding' has no converter対応中かも @mattn が 7 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 13 日以内に返信
-
GTK4 build's v:servername is prefixed with $XDG_RUNTIME_DIR/vim再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 13 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 13 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 13 日以内に返信
似ている issue
-
Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
Support FORCE_COLORオープンenhancement good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
bug release-blocker
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
tonydzi/sqlite-graph-memory#133 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100