Minga.Buffer.EditDelta (Minga v0.1.0)

Copy Markdown View Source

Describes a single edit applied to a buffer's content.

Edit deltas are used for incremental content sync with the tree-sitter parser process. Instead of sending the entire file content after each change, the BEAM sends compact deltas that describe what changed and where. The parser applies these to its stored copy of the source and performs an incremental reparse.

Fields

  • start_byte — byte offset where the edit begins
  • old_end_byte — byte offset where the old (removed) text ends
  • new_end_byte — byte offset where the new (inserted) text ends
  • start_position{line, col} at start_byte
  • old_end_position{line, col} at old_end_byte
  • new_end_position{line, col} at new_end_byte
  • inserted_text — the text that was inserted (empty for pure deletions)

Summary

Functions

Creates a delta for a deletion at a position (no text inserted).

Creates a delta for an insertion at a position (no text removed).

Creates a delta for a replacement (text removed and text inserted).

Types

t()

@type t() :: %Minga.Buffer.EditDelta{
  inserted_text: String.t(),
  new_end_byte: non_neg_integer(),
  new_end_position: {non_neg_integer(), non_neg_integer()},
  old_end_byte: non_neg_integer(),
  old_end_position: {non_neg_integer(), non_neg_integer()},
  start_byte: non_neg_integer(),
  start_position: {non_neg_integer(), non_neg_integer()}
}

Functions

deletion(start_byte, old_end_byte, start_position, old_end_position)

Creates a delta for a deletion at a position (no text inserted).

insertion(byte_offset, arg1, text, arg2)

Creates a delta for an insertion at a position (no text removed).

replacement(start_byte, old_end_byte, start_position, old_end_position, new_text, new_end_position)

Creates a delta for a replacement (text removed and text inserted).