CollaborativeString.setText 不会导致 "minimum number of" 编辑

CollaborativeString.setText does not result in "minimum number of" edits

CollaborativeString.setText: Sets the contents of this collaborative string. Note that this method performs a text diff between the current string contents and the new contents so that the string will be modified using the minimum number of text inserts and deletes possible to change the current contents to the newly-specified contents.

这是一个小问题,但文档在技术上不准确。将一个字符串更改为另一个字符串的最小编辑次数始终最多为 2:删除整个字符串并插入新字符串。

例如,要更改,将 baaaaaaaab 更改为 caaaaaaaac,实时 api 会做明智的事情,即为每个 b 使用一个删除事件,为每个 c 使用一个相应的插入事件。

出于好奇,是否可以为此制定确切的文本差异算法 public?我尝试了几种 diff 算法,但没有重现确切的算法。

我想文档并不完全清楚,但它是达到最终状态的最小插入和删除次数无需 重述保持不变的内容。

我怀疑我们是否想要说明有关该算法的任何更具体的内容,因为它如有更改,恕不另行通知:)你为什么关心?