-
-
Notifications
You must be signed in to change notification settings - Fork 461
Closed
Description
Describe the issue
I noticed while using the merge package in my Obsidian plugin that when updating an existing chunk via updateB on, which reverts any changes to an empty document, the old chunk is still preserved. This results in a chunk referring to positions that no longer exist. It can be reproduced by the following test. It does not just apply to a single character, but if one document is empty and the other other is empty after the change as well.
it("properly handles changes to empty doc", () => {
let sA = EditorState.create({doc: ``})
let sB = EditorState.create({doc: `a`})
let chs = Chunk.build(sA.doc, sB.doc)
ist(chs.length, 1)
// Remove the single character 'a' from sB, which should clear the single chunk
let tr = sB.update({changes: {from: 0, to: 1,}})
let updated = Chunk.updateB(chs, sA.doc, tr.newDoc, tr.changes)
ist(updated.length, 0)
})This is a regression by a fix to my last issue report: #1634 codemirror/merge@fe6b1ad. v6.11.1 does not have this issue in my plugin.
Browser and platform
Observed in Obsidian, Electron, but reproduce as well in nodejs v24.11.0
Reproduction link
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels