ChangeSet

A change set represents a group of modifications to a document. It stores the document length, and can only be applied to documents with exactly that length.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Get a change description for this change set.

Link copied to clipboard

False when there are actual changes in this set.

Link copied to clipboard

Get a description of the inverted form of these changes.

Link copied to clipboard
val length: Int

The length of the document before the change.

Link copied to clipboard

The length of the document after the change.

Functions

Link copied to clipboard
fun apply(doc: Text): Text

Apply the changes to a document, returning the modified document.

Link copied to clipboard

Combine two subsequent change sets into a single set. other must start in the document produced by this.

Link copied to clipboard

Compute the combined effect of applying another set of changes after this one. The length of the document after this set should match the length before other.

Link copied to clipboard
fun invert(doc: Text): ChangeSet

Given the document as it existed before the changes, return a change set that represents the inverse of this set, which could be used to go from the document created by the changes back to the document as it existed before the changes.

Link copied to clipboard
fun iterChangedRanges(f: (fromA: DocPos, toA: DocPos, fromB: DocPos, toB: DocPos) -> Unit, individual: Boolean = false)

Iterate over the ranges changed by these changes.

Link copied to clipboard
fun iterChanges(f: (fromA: DocPos, toA: DocPos, fromB: DocPos, toB: DocPos, inserted: Text) -> Unit, individual: Boolean = false)

Iterate over the changed ranges in the document.

Link copied to clipboard
fun iterGaps(f: (posA: DocPos, posB: DocPos, length: Int) -> Unit)

Iterate over the unchanged parts left by these changes. posA provides the position of the range in the old document, posB the new position in the changed document.

Link copied to clipboard
fun map(other: ChangeDesc, before: Boolean = false): ChangeSet

Given another change set starting in the same document, maps this change set over the other, producing a new change set that can be applied to the document produced by applying other.

Link copied to clipboard
open override fun mapDesc(other: ChangeDesc, before: Boolean = false): ChangeDesc

Map this description, which should start with the same document as other, over another set of changes, so that it can be applied after it. When before is true, map as if the changes in this happened before the ones in other.

Link copied to clipboard
fun mapPos(pos: DocPos, assoc: Int = -1): DocPos

Map a given position through these changes, to produce a position pointing into the new document.

fun mapPos(pos: DocPos, assoc: Int, mode: MapMode): DocPos?

Map a given position through these changes. Returns null if the position was deleted according to the given mode.

Link copied to clipboard

Serialize this change set to a JSON-representable value.

Link copied to clipboard
fun toJSON(): List<Int>

Serialize this change desc to a JSON-representable value.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun touchesRange(from: DocPos, to: DocPos = from): TouchesResult

Check whether these changes touch a given range. When one of the changes entirely covers the range, the string "cover" is returned.