Type Editor / @type-editor/changeset / compute-diff / computeDiff
Function: computeDiff()
ts
function computeDiff<T>(fragA, fragB, range, encoder?): Change<any>[];Defined in: compute-diff.ts:24
Compute the difference between two fragments using Myers' diff algorithm.
This implementation optimizes by first scanning from both ends to eliminate unchanged content, then applies the Myers algorithm to the remaining content. For performance reasons, the diff computation is limited by MAX_DIFF_SIZE.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
fragA | Fragment | The first fragment to compare. |
fragB | Fragment | The second fragment to compare. |
range | Change | The change range to analyze. |
encoder | TokenEncoder<T> | The encoder to use for tokenization (defaults to DefaultEncoder). |
Returns
Change<any>[]
An array of Change objects representing the differences.