Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Bug: Undo History Not Working for Accept Changes in UnifiedMergeView

Đang mở
#714 0 bình luận 4 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu bằng cách chạy reproduction unifiedMergeView được cung cấp với mergeControls và history extension, sau đó theo dõi cách Accept và Reject dispatch các thay đổi của chúng. Xác nhận hành vi dựa trên các kỳ vọng undo đã nêu và xác định điểm tích hợp liên quan trước khi thêm regression test; hoàn tất có nghĩa là các thay đổi được chấp nhận có thể được undo giống như các thay đổi bị từ chối.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

  1. 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",
      }}
    />
  );
}
});
  1. Click the "Accept" button in merge controls
  2. Try to undo the accept operation with Ctrl+Z/Cmd+Z
  3. Expected: Changes are undone, Actual: Nothing happens
  4. Click the "Reject" button in merge controls
  5. Try to undo the reject operation with Ctrl+Z/Cmd+Z
  6. 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",
Ngôn ngữ chính
TypeScript
Star
2.3k
Fork
162
Merge trung bình
2 giờ 41 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của uiwjs/react-codemirror

Tất cả issue của uiwjs/react-codemirror

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.