TextEdit class

Describes a text edit operation (inspired by tree-sitter's TSInputEdit).

Indicates that the region [startOffset, oldEndOffset) in the old text is replaced with new content, and the region becomes [startOffset, newEndOffset) after replacement.

Examples:

  • Insert 3 characters at position 5: TextEdit(5, 5, 8)
  • Delete characters from position 5 to 8: TextEdit(5, 8, 5)
  • Replace characters 5 to 8 with 2 characters: TextEdit(5, 8, 7)

Constructors

TextEdit(int startOffset, int oldEndOffset, int newEndOffset)
const

Properties

delta int
Offset change (new length - old length)
no setter
hashCode int
The hash code for this object.
no setterinherited
isDeletion bool
Whether it is a pure deletion operation
no setter
isInsertion bool
Whether it is a pure insertion operation
no setter
newEndOffset int
Edit end position (offset in the new text)
final
newLength int
Length of the inserted/replaced portion in the new text
no setter
oldEndOffset int
Edit end position (offset in the old text)
final
oldLength int
Length of the deleted/replaced portion in the old text
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startOffset int
Edit start position (offset in the old text)
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

diff(String oldText, String newText) TextEdit
Automatically calculates an edit from the differences between two strings. Finds the longest common prefix and suffix; the middle portion is the edit region.
fromAppend(int oldLength, int newLength) TextEdit
Calculates an edit from the "old text is a prefix of new text" (append scenario)