search

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package search implements a directional substring search index for diff lines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index holds a searchable list of line texts extracted from a FilePatch.

func Build

func Build(patch model.FilePatch) *Index

Build constructs an Index from all DiffLines in the patch's hunks. Hunk headers are not included in the index.

func (*Index) Find

func (idx *Index) Find(query string, fromLine int, dir SearchDirection) (int, bool)

Find searches for query starting from fromLine in the given direction. It returns the matching line index and true, or (0, false) if not found. Empty query always returns (0, false). Search wraps around.

func (*Index) Len

func (idx *Index) Len() int

Len returns the number of indexed lines.

type SearchDirection

type SearchDirection int

SearchDirection indicates which way to scan.

const (
	SearchNext SearchDirection = iota
	SearchPrev
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL