Skip to content

feat(undo): use Y.UndoManager for collaborative Ctrl+Z, fix ASAR activation on VS Code 1.130 - #17

Open
ChenyuHeee wants to merge 1 commit into
kermanx:mainfrom
ChenyuHeee:fix/issue-7-undo-redo
Open

feat(undo): use Y.UndoManager for collaborative Ctrl+Z, fix ASAR activation on VS Code 1.130#17
ChenyuHeee wants to merge 1 commit into
kermanx:mainfrom
ChenyuHeee:fix/issue-7-undo-redo

Conversation

@ChenyuHeee

@ChenyuHeee ChenyuHeee commented Aug 6, 2026

Copy link
Copy Markdown

修复内容

1. Ctrl+Z 协同撤销 (#7)

之前 VS Code 原生 range-based undo 在并发编辑时可能删错 CRDT items,且远程变更会污染本地的撤销栈。

改用 Y.UndoManager 做 per-user undo:

  • common.ts — 每个 Y.Doc 创建 UndoManager(trackedOrigins 只追踪本地变更)
  • 拦截 Ctrl+Z/Ctrl+Shift+Z 快捷键(p2p-live-share:inSession 时),无 UndoManager 时自动 fallback 到原生 undo
  • host 和 guest 两端都生效

2. VS Code 1.130 激活崩溃 (#16)

VS Code 1.130 (Electron 42) 将 node-pty 打包在 node_modules.asar 中,fs.existsSync 无法检测。改为三层 fallback:

  1. node_modules/ 路径(旧版 VS Code / 开发环境)
  2. node_modules.asar.unpacked/ 路径(原生二进制模块)
  3. node_modules.asar/ 路径(Electron require 透明处理)

测试

  • 新增 src/fs/undo-manager.test.ts(4 个 Y.UndoManager 并发编辑测试)
  • 新增 src/terminal/pty/shims/utils.test.ts(4 个路径解析测试)
  • 真实环境验证:两台 Linux VS Code 1.130,Ctrl+Z 各自撤销各自的编辑,互不干扰

Closes #7, Closes #16

@ChenyuHeee
ChenyuHeee force-pushed the fix/issue-7-undo-redo branch from 594b9bf to bf46cdc Compare August 6, 2026 08:28
…ermanx#7, kermanx#16)

- Use Y.UndoManager with trackedOrigins for per-user collaborative undo
- Intercept Ctrl+Z/Ctrl+Shift+Z via keybindings with native fallback
- Fix extension activation on VS Code >= 1.130 where node-pty is bundled
  inside node_modules.asar — add three-tier path fallback
- Add tests: Y.UndoManager behavior (4 tests) + resolveAsset paths (4 tests)
@kermanx

kermanx commented Aug 26, 2026

Copy link
Copy Markdown
Owner

感谢 PR~

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.

unsync control + z Extension fails to activate: Asset not found: node-pty/lib/index.js (v0.0.23)

2 participants