View Source Lexical.Document.Position (lexical_shared v0.5.0)

A position inside of a document

This struct represents a cursor position inside a document, using one-based line and character numbers. It's important to note that the position starts before the character given, so positions are inclusive of the given character.

Given the following line of text: "Hello there, welcome to lexical"

the position: %Lexical.Document.Position{line: 1, character: 1} starts before the "H" in "Hello"

Link to this section Summary

Link to this section Types

@type character() :: non_neg_integer()
@type line() :: non_neg_integer()
@type line_container() :: Lexical.Document.t() | Lexical.Document.Lines.t()
@type t() :: %Lexical.Document.Position{
  character: character(),
  context_line: Lexical.Document.Line.t() | nil,
  document_line_count: non_neg_integer(),
  line: line(),
  starting_index: non_neg_integer(),
  valid?: boolean()
}

Link to this section Functions

Link to this function

new(document, line, character)

View Source
@spec new(line_container(), line(), character()) :: t()