Gitility.SearchMatch (Gitility v0.4.0)

Copy Markdown View Source

One match from a snapshot content search.

Carries enough identity for a stable citation: the snapshot's commit, the matched blob, the path, and the position. line is 1-based; column is a 0-based byte offset into the line (content is bytes; a character column would presuppose an encoding).

preview is the matched line (or its 1 KiB capped prefix) as raw bytes; preview_truncated explicitly records whether that cap was applied; context_before/context_after carry surrounding lines when context_lines: was requested. submatches gives the byte ranges of each retained match within the preview line. At most 256 ranges are retained; occurrences beginning beyond the preview are omitted, and submatches_truncated records either form of omission.

Context blocks belong to each match independently, so adjacent matches may repeat the same context lines. Unlike git grep -C, hunks are not merged.

Summary

Types

A byte range beginning within the preview line; zero-length regex matches retain length 0.

t()

Types

submatch()

@type submatch() :: {non_neg_integer(), non_neg_integer()}

A byte range beginning within the preview line; zero-length regex matches retain length 0.

t()

@type t() :: %Gitility.SearchMatch{
  blob_oid: Gitility.OID.t(),
  column: non_neg_integer(),
  commit_oid: Gitility.OID.t(),
  context_after: [binary()],
  context_before: [binary()],
  line: pos_integer(),
  path: binary(),
  preview: binary(),
  preview_truncated: boolean(),
  submatches: [submatch()],
  submatches_truncated: boolean()
}