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

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.ts — GlobalConfig 加 vimInsertModeRemaps?: 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 [email protected]

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 <[email protected]>
@dahai80
dahai80 merged commit 3a17239 into main Aug 20, 2026
1 check passed
dahai80 added a commit that referenced this pull request Aug 22, 2026
Patch release bundling 17 commits since v0.4.23:
- item 15(a) MLX OOM auto-recovery gc+retry (#129)
- #7 one-click diagnostic fixAction framework (#131)
- 维度5 background-default spawn FUSION_SUBAGENT_DEFAULT_BACKGROUND (#127)
- #4 proactive MLX OOM detection via /v1/health (#125)
- item 17 fullscreen pre-compact history + :598 synthetic decouple (#123)
- item 25B workflow stagger fan-out (#122)
- item 21 auto-mode local rule classifier test coverage (#120)
- item 23 archive plugin source + SHA-256 lock (#118)
- item 24 marketplace command source (#116)
- item 6 transcript disk trimming + crash-safe checkpoint (#114)
- item 5 normalizeMessages secondary normalize cache (#112)
- item 19 screen-reader plaintext render (#110)
- item 16 compact retry countdown + stall hint (#108)
- item 25A workflow execution runtime docs (#106)
- item 25A minimal workflow execution runtime (#105)
- item 12 subagent auto-background threshold (#103)
- item 20 vimInsertModeRemaps dual-key INSERT sequence (#101)

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 deleted the feat/item20-vim-insert-remaps branch August 25, 2026 09:23
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