Bug: Undo History Not Working for Accept Changes in UnifiedMergeView
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- react, typescript
- 领域
- frontend
调研方向
首先运行提供的、使用 mergeControls 和 history extension 的 unifiedMergeView 复现,然后跟踪 Accept 和 Reject 如何 dispatch 它们的更改。根据所述的 undo 预期确认行为,并在添加回归测试之前确定相关的集成点;完成的标准是接受的更改可以像拒绝的更改一样被 undo。
由索引模型根据 Issue 内容生成。
描述
Description
When using unifiedMergeView with mergeControls: true, the undo history functionality (Ctrl+Z/Cmd+Z) only works for rejected changes but not for accepted changes. The expected behavior is that both accept and reject operations should be undoable.
Steps to Reproduce
- Create a basic setup with
unifiedMergeView:
"use client";
import React, { useEffect, useRef } from "react";
import { EditorView, keymap } from "@codemirror/view";
import { unifiedMergeView } from "@codemirror/merge";
import { javascript } from "@codemirror/lang-javascript";
import { oneDark } from "@codemirror/theme-one-dark";
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
export default function DemoMergeIssue() {
const editorRef = useRef(null);
const commonExtensions = [
javascript({ jsx: true, typescript: true }),
oneDark,
history(),
keymap.of(defaultKeymap),
keymap.of(historyKeymap),
];
useEffect(() => {
if (editorRef.current) {
// Create a unified merge view.
const view = new EditorView({
doc: "console.log('Modified Code');",
extensions: [
...commonExtensions,
oneDark,
javascript(),
unifiedMergeView({
original: "console.log('Original Code');",
highlightChanges: true,
mergeControls: true,
}),
],
parent: editorRef.current,
});
return () => view.destroy();
}
}, []);
return (
<div
ref={editorRef}
style={{
height: "400px",
border: "1px solid #ccc",
borderRadius: "4px",
margin: "1rem 0",
}}
/>
);
}
});
- Click the "Accept" button in merge controls
- Try to undo the accept operation with
Ctrl+Z/Cmd+Z - Expected: Changes are undone, Actual: Nothing happens
- Click the "Reject" button in merge controls
- Try to undo the reject operation with
Ctrl+Z/Cmd+Z - Expected: Changes are undone, Actual: Changes are undone successfully
Analysis
The issue appears to be related to how the unified merge view handles history states for accept operations. While reject operations properly integrate with the history extension, accept operations seem to bypass the history mechanism.
Environment
"@codemirror/commands": "^6.8.0",
"@codemirror/lang-javascript": "^6.2.3",
"@codemirror/merge": "^6.8.0",
"@codemirror/state": "^6.5.2",
"@codemirror/theme-one-dark": "^6.1.2",
"@codemirror/view": "^6.36.3",
- 主要语言
- TypeScript
- 星标
- 2.3k
- 派生
- 162
- 平均合并
- 2 小时 41 分钟
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
uiwjs/react-codemirror 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
uiwjs/react-codemirror#766 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
uiwjs/react-codemirror#765 ·
-
难度 3/5 1-2 天 新手友好度 35/100
uiwjs/react-codemirror#772 ·
-
难度 4/5 3-5 天 新手友好度 48/100
uiwjs/react-codemirror#770 ·
-
难度 3/5 1-2 天 新手友好度 48/100
uiwjs/react-codemirror#767 · 2 条评论 ·
查看 uiwjs/react-codemirror 的全部 Issue
相似的 Issue
-
The inspector never shows the instances field, so scaling out is unreachable可能已有人在做 @Mrkewl 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
xevrion/breakscale#96 ·
维护者通常 4 天内回复
-
Object parameters lose their structure when resources is enabled可能已有人在做 @asts-top 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
rossant/awesome-math#199 ·
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
jaegertracing/jaeger-ui#4618 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
mifi/lossless-cut#3125 ·
维护者通常 1 天内回复