Say I have a command that operates on the entire buffer.
The simple solution is to:
- Run the command taking the entire buffer as input.
- Store the output.
- Clear the current buffer.
- Insert the new contents.
The problem with this is it's quite slow and it seems the undo system stores a lot of data for this operation.
In cases where only a few changes are made - is there a way to only apply changes - in a way doesn't require the heavy operation of replacing the entire contents?
Something like creating a diff and applying it, instead of replacing the entire buffer, however it need not use the diff format.
Or do I need to write my own code to detect differences and apply them as edits?