打ち続けて確定した変換も確定アンドゥで取り消せるようにする - #258
Merged
Merged
Conversation
kakuteiUndo could only take back a kakutei done by a kakutei key. A candidate is confirmed by typing on as well, and the same key handling then writes the input of that key behind the confirmed string. The pending kakutei is resolved at the next key handling by looking for the confirmed string at the end of the line before the cursor, which no longer matched, so the record was dropped and there was nothing left to take back. A completion confirmed by typing on has the same shape: the key which closes the popup is handled before CompleteDone reports the kakutei, hence the pre-edit of that key sits behind the confirmed string as well. Remember what the rest of the key handling writes behind a recorded kakutei, and strip it, along with the pre-edit which is in the buffer, before looking for the confirmed string. Nothing is stripped when the line does not end with it, which is what a completion confirmed from the popup looks like: the engine has rewritten the buffer and the pre-edit skkeleton remembers is a stale one. That path resolves as it did before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Shougo
approved these changes
Sep 17, 2026
Contributor
|
マージします |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#257 で入れた確定アンドゥが、
<C-j>などの確定キーを押さずに打ち続けて確定した場合に利用出来なくなっていました。再現
<C-z>にkakuteiUndoを割り当てます。KiMeと打って ▼決め を出し、確定キーを押さずにそのままruと打ちます。「決め」が確定して「決める」になります。<C-h>で「る」を消すと確定した文字列がカーソルの直前に戻りますが、ここで<C-z>を押しても何も起きません。ruの前に<C-j>を挟んで確定した場合は「▼決め」に戻ります。補完でも同じことが起きます。候補を選んだまま打ち続けて確定すると、ポップアップを閉じたキーの pre-edit が確定した文字列の後ろに並ぶため、同じように取り消せませんでした (ポップアップから
<C-y>などで確定した場合は取り消せます)。原因
確定した文字列がバッファのどの位置に入ったかは次のキー処理まで分からないので、カーソル前の行がその文字列で終わっているかどうかで判断していました。打ち続けての確定では、確定させたキー自身の入力が同じキー処理の中で確定した文字列の後ろに並びます。その場合想定と違う文字列になるため、記録を捨てていました。
直し方
確定を記録した後に同じキー処理が書いた分を覚えておき、それと現在の preEdit を取り除いてから、確定した文字列を探すようにしました。これが想定と一致していれば記録として残します。
実バッファ (Neovim) の統合テストを 1 本足しました。ドキュメントに書いた「続けて入力した文字を消してカーソルが戻った場合も動作します」のとおりになるだけなので、
doc/は変更していません。#257 で相談していた件とは別に入れたい修正です。
🤖 Generated with Claude Code