Skip to content

[Bug] 撤销(command+Z)会把内容清空 #5028

Closed

Description

@wsyu52

Description

当编辑文件时,按cmd+z,退回到文件初始状态后,再按(比如连续按不小心按多了),文件内容会被清空

Steps to Reproduce

打开一个md文件,编辑后,连续按cmd+z撤销

Expected Behavior

当内容已经还原到文件原始状态时,再按cmd+z,保持文件原始打开时的内容

Actual Behavior

文件内容清空

Screenshots / Logs

No response

Operating System

macOS

MarkText Version

0.19.1

OS Version

macos14

Reproducibility

  • I can reliably reproduce this issue

Activity

  1. Jocs commented on Sep 11, 2026

    @Jocs
    Member

    感谢反馈!我按你的步骤在 0.19.1 上复现了这个问题,但在 0.20.0 预发布版里已经不再出现,所以先关闭这个 issue。

    复现步骤:打开内容为 # Title + hello world 的文件 → 分两次编辑(中间停顿) → 通过「编辑 › 撤销」同一路径连续撤销 20 次。

    版本 随应用启动一起打开的文件 在已运行窗口中打开的文件
    0.19.1 ❌ 第 4 次撤销后文档变为空白 ✅ 停在文件原始内容
    0.20.0-rc.1 ✅ 停在文件原始内容 ✅ 停在文件原始内容
    develop (d19370f) ✅ ✅

    在 develop 上还额外验证了:切换标签页后再撤销、在源码模式里编辑后再撤销、快速连按撤销,内容都停在文件打开时的状态。

    原因:0.19.1 使用旧的编辑器引擎,随启动打开的文件在撤销到原始内容后还能继续撤销到一个空文档。0.20.0 换成了新引擎 @muyajs/core:加载文档时会清空撤销历史,撤销栈为空时再按撤销不做任何事。

    可以试试 0.20.0-rc.1。如果在 0.20.0 上仍能复现,请回复具体步骤,我们会重新打开。


    Summary: Reproduced on 0.19.1 — for a file opened at launch, the 4th undo past the original content empties the document (files opened into a running window were fine). Not reproducible on 0.20.0-rc.1 or develop (argv launch, open into running window, tab-switch round trip, source-mode edit, rapid undos): the new @muyajs/core engine clears history when a document loads and ignores undo on an empty stack. Closing; please reopen with steps if it happens on 0.20.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions