Skip to content

feat(canvas): 删节点、删连线、拖卡换泳道可撤销,撤销卡撤的是卡上那一步(第二批 W3 · undo-adopt-existing) - #322

Merged
KerroKapple merged 3 commits into
mainfrom
feat/b2-undo-adopt-existing
Oct 30, 2026
Merged

KerroKapple merged 3 commits into
mainfrom
feat/b2-undo-adopt-existing

Conversation

@KerroKapple

Copy link
Copy Markdown
Owner

删节点(单删 / 多删)、删连线、拖卡换泳道,现在都记进画布撤销栈:Ctrl Z / ⌘Z 能撤,撤销卡上的「撤销」撤的是卡上那一步(不是栈顶),关掉画布后残留的卡点了不再生效。

改了什么

  • 新 models/commands/:DeleteNodesCommand(复原 = restoreAll,返回 0 ⇒ 这一步作废;复原里含导入节点时让节点控制器重载)、DeleteEdgeCommand(按两端找边,同两端已有在世边 ⇒ 不重复复原)、MoveNodesCommand(回到原位置与原泳道;步名存泳道原名,显示时才落成「未命名」)。
  • util/canvas_edge_delete.dart:deleteEdgeWithUndo,舞台连线删除键与检查器输入行「移除」共用;context / ref 在第一次 await 前取齐。检查器「移除」失败现在会出错误卡(以前静默吞掉)。
  • canvas_snackbars.dart:新增 showCanvasUndoSnackWith(按步撤 + 绑卡,步被撤掉 / 画布关闭 ⇒ 卡收起);showCanvasUndoSnack 保留两种用法(按步登记 / 只给 onUndo 回调)。泳道解散 / 删除仍走 showUndoToast,不变。
  • 新文案键 5 个(步名:删除 N 个节点 / 删除连线 / 移动 N 个节点 / 移入泳道「x」/ 移出泳道「x」)。

已知、不在本 PR 修

  • 写库那一下(单次 await)期间如果切走了画布,这一步会记进旧画布的栈。窗口只有一次写库,留给 W6 undo-lanes 一并收。

验证(最终 head)

  • flutter analyze lib test:No issues found
  • flutter test -j 4 --exclude-tags golden:4017 全绿
  • 变异 29/29 变红:单删 / 多删不入栈、卡按钮撤栈顶而不是本步、不绑卡、restoreAll 返回 0 不作废、导入节点不重载 / 每次都重载、删边按快照 id 找、复原前不查在世边 / 端点、移动回退方向、换道不入栈 / 不出卡、检查器移除吞错、失败仍入栈、多删文案、按钮文案不走 l10n 等。

🤖 Generated with Claude Code

KerroKapple and others added 3 commits October 29, 2026 18:59
- 新增 models/commands/:DeleteNodesCommand(restoreAll 一次复原,0 行 ⇒ gone,含导入节点时重载节点控制器;
  重做换新令牌)、DeleteEdgeCommand(按两端 + 类型找边,同两端已有在世边视为已复原)、
  MoveNodesCommand + MoveNodesLabel(位移按目标 − 此刻位置算,一次 moveNodes)
- 新增 util/canvas_edge_delete.dart 的 deleteEdgeWithUndo:舞台选中线的 ✕ 与检查器入边区「移除」共用,
  检查器移除失败不再吞掉
- canvas_node_delete:成功即 record + 按步出卡,不再以 context.mounted 为前提;删掉 _restore / _restoreAll
- canvas_snackbars:showCanvasUndoSnack 增加按步用法(canvasId + stepId),新增不依赖 context 的
  showCanvasUndoSnackWith(卡上「撤销」= runCanvasUndoStep,卡绑到步上随步收起);showUndoToast 原样保留
- node_card_slot:换道成功后 record MoveNodesCommand 并按步出卡,删掉闭包撤销
- 测试:三个命令测试、删节点撤销栈用例、换道 Ctrl Z、撤销卡按步 / 收卡、检查器移除失败;canvas_view_test 只改 fake

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KerroKapple
KerroKapple merged commit a1c0e04 into main Oct 30, 2026
5 checks passed
@KerroKapple
KerroKapple deleted the feat/b2-undo-adopt-existing branch October 30, 2026 14:33
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.

1 participant