feat(vim): item 20 vimInsertModeRemaps 双键 INSERT 序列映射 (jj→Esc, CC 2.1.208) - #101
Merged
Conversation
GlobalConfig 加 vimInsertModeRemaps?: string[] (default off)。ConfigTool 暴露为 /config 可设项 (type array)。useVimInput INSERT 分支加状态序列 检测器: 首键暂存前缀+插入+起超时窗; 次键完整匹配→回溯删已插前缀 (Cursor.backspace)+insertedText 镜像减(防 dot-repeat 重放)+切 NORMAL; 非前缀→放弃序列正常插入; 超时/backspace/Esc 中断清状态。 纯函数 matchInsertRemap + getInsertRemapTimeoutMs(env FUSION_VIM_INSERT_REMAP_TIMEOUT_MS default 750, fail-open) 便于单测。 卸载 useEffect 清定时器防 leak。空 remaps byte-identical 旧行为。 验证: typecheck 0; 单测 13 pass; 全 180 单测 pass; build + build:dev:full pass。 Closes #100 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
enhance-0819.md §207 item 20 —
vimInsertModeRemaps(双键 INSERT 序列映射jj→Esc), CC 2.1.208。仓库有完整 vim 引擎但 INSERT 模式无双键 exit 序列映射。本 PR 落地全量
jj→Esc 能力 (用户确认 "全量 jj→Esc")。Changes
src/utils/config.ts—GlobalConfig加vimInsertModeRemaps?: string[](sibling toeditorMode)src/tools/ConfigTool/supportedSettings.ts— 暴露为/config可设项 (type: "array", source global)src/hooks/useVimInput.ts— INSERT 分支状态序列检测器:matchInsertRemap(remaps, prefix, input)→{action, newPrefix}getInsertRemapTimeoutMs()(envFUSION_VIM_INSERT_REMAP_TIMEOUT_MS, default 750, fail-open)Cursor.backspace)+insertedText镜像减(防 dot-repeat 重放)+切 NORMAL; 非前缀→放弃序列正常插入; 超时清前缀; backspace/Esc 中断清状态useEffect清定时器防 leaksrc/__tests__/vimInsertRemaps.test.ts— 纯函数 13 case (match 8 + timeout 5)设计决策
/config vimInsertModeRemaps ["jj"]启用matchInsertRemap无副作用, 确定性判定不经模型 (Rule 5), 便于单测Cursor.backspace(): 处理多字节 grapheme, 同 createOperatorContext setText 模式insertedText镜像减已删前缀, 防.重放多余字符验证
Closes #100
Co-Authored-By: Claude Fable 5 noreply@anthropic.com