>> Does this mean that code in, say, an existing plugin won't work if it 
uses the currently-existing  before/afterChangeTree calls?

> Yes. Those calls are dangerous.

Plugins have three ways forward:

1. Replace the existing undo calls with a call to u.clearAndWarn.

The code is no longer undoable but is already an improvement! Undo/redo 
won't corrupt the undo state.

2. Follow the pattern of the git-diff commands. That is:

- Place all changes in a *single* new node.
- Call u.before/afterInsertNode instead of u.before/afterChangeTree.

Now the plugin has *safe* undo/redo.

3. Follow the pattern of 'parse-body`. Write bespoke undo/redo handlers.

Plugins will rarely need to do this, but it's straightforward.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/522fda13-f092-4dc8-be01-c986293ef0d2n%40googlegroups.com.

Reply via email to