Skip to content

feat(vim): item 20 vimInsertModeRemaps 双键 INSERT 序列映射 (jj→Esc, CC 2.1.208) - #101

Merged
dahai80 merged 1 commit into
mainfrom
feat/item20-vim-insert-remaps
Aug 20, 2026
Merged

feat(vim): item 20 vimInsertModeRemaps 双键 INSERT 序列映射 (jj→Esc, CC 2.1.208)#101
dahai80 merged 1 commit into
mainfrom
feat/item20-vim-insert-remaps

Conversation

@dahai80

@dahai80 dahai80 commented Aug 20, 2026

Copy link
Copy Markdown
Owner

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.tsGlobalConfigvimInsertModeRemaps?: string[] (sibling to editorMode)
  • src/tools/ConfigTool/supportedSettings.ts — 暴露为 /config 可设项 (type: "array", source global)
  • src/hooks/useVimInput.ts — INSERT 分支状态序列检测器:
    • 纯函数 matchInsertRemap(remaps, prefix, input){action, newPrefix}
    • getInsertRemapTimeoutMs() (env FUSION_VIM_INSERT_REMAP_TIMEOUT_MS, default 750, fail-open)
    • 首键暂存前缀+插入+起超时窗; 次键完整匹配→回溯删已插前缀(Cursor.backspace)+insertedText 镜像减(防 dot-repeat 重放)+切 NORMAL; 非前缀→放弃序列正常插入; 超时清前缀; backspace/Esc 中断清状态
    • 卸载 useEffect 清定时器防 leak
    • 空 remaps (default) byte-identical 旧行为
  • src/__tests__/vimInsertRemaps.test.ts — 纯函数 13 case (match 8 + timeout 5)

设计决策

验证

  • typecheck: 0 errors
  • 新单测: 13 pass
  • 全单测: 180 pass, 0 fail
  • build + build:dev:full: pass
  • changed 文件 lint clean (config.ts 2 pre-existing baseline errors 在 724/1186, 非本次)

Closes #100

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

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>
@dahai80
dahai80 merged commit 3a17239 into main Aug 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(item 20): vimInsertModeRemaps 双键 INSERT 序列映射 (jj→Esc, CC 2.1.208)

1 participant