forEachChange
public inline fun ChangeList.forEachChange(
block: (range: TextRange, originalRange: TextRange) -> Unit
)
Iterates over all changes in this ChangeList in order of their appearance in the text (from the lowest character offset to the highest).
In each iteration, block receives range (the range of the change in the updated TextFieldBuffer) and originalRange (the corresponding range in the original text buffer before any changes).
Avoid modifying text before the current range. Changes are ordered by character offset, so modifying text earlier in the buffer shifts the current change to a higher index in the ChangeList. Because this function iterates forward by index, it will mistakenly visit the current change again and skip the newly inserted change.
For example, assume ChangeList initially has one change at 5..8. If block inserts text at index 0, a new change at 0..2 is placed at index 0, and the original change is shifted to index 1. As the loop advances to index 1, it visits the original change a second time.
Parameters
| block | The block to be invoked for each change. |