# 防止与过期的快照或位置进行差异比较

**URL:** <https://meta.discourse.org/t/prevent-diffing-against-a-stale-snapshot-or-position/407261>\
**Category:** Bug\
**Tags:** shared-edits\
**Created:** [2026年七月10日 12:16 UTC](https://meta.discourse.org/t/prevent-diffing-against-a-stale-snapshot-or-position/407261 "2026-07-10T12:16:47Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![klappradla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/klappradla/32/531604_2.png) [@klappradla](https://meta.discourse.org/u/klappradla)\
**Post date:** [2026年七月10日 12:16 UTC](https://meta.discourse.org/t/prevent-diffing-against-a-stale-snapshot-or-position/407261/1 "2026-07-10T12:16:47Z")

</div>

在对多个用户通过 [shared-edits 插件](https://meta.discourse.org/t/discourse-shared-edits/167583) 同时编辑共享帖子的用户体验进行测试时，我遇到了一些场景：新增内容的部分被静默丢弃，或者新内容在不考虑单词边界等因素的情况下，以奇怪的方式混入现有内容中。

原来，插件代码中有两处地方，在并发编辑的场景下，用户会收到基于内容 **过时快照** 应用的更改，而不是基于他们实际看到的内容。

我更新了代码，使差异比较基于编辑器/DOM 的实际当前状态，而不是之前捕获的快照。详情请参见 [对应的 PR](https://github.com/discourse/discourse-shared-edits/pull/165)。

应用此更改后，我觉得整体用户体验变得更加流畅，即使是在同时编辑文档中的同一位置时。结果更具可读性，减少了单词内部混乱的情况。

_(背景信息：我正在使用 Playwright 运行自动化测试，对帖子进行并发编辑。)_

---

_[View the full topic](https://meta.discourse.org/t/prevent-diffing-against-a-stale-snapshot-or-position/407261)._
