Documentation
¶
Overview ¶
Package textsearch shares find/replace semantics between the editor and server.
Index ¶
- func LiteralArgs(query string, sensitive bool) []string
- type Match
- type Options
- type Pattern
- func (p *Pattern) DiskFilter() (literal string, caseSensitive bool)
- func (p *Pattern) FindAll[T string | []byte](content T, dst []Match, limit int) []Match
- func (p *Pattern) FindRange[T string | []byte](content T, dst []Match, start, end, limit int, countAll bool) ([]Match, int)
- func (p *Pattern) FindSnapshot(content piecetree.Snapshot, dst []Match, start, end, limit int) []Match
- func (p *Pattern) Literal() bool
- func (p *Pattern) LiteralMatches(ctx context.Context, source io.Reader, ...) error
- func (p *Pattern) Replace(content, replacement string, matches []Match) string
- func (p *Pattern) Replacement(content string, match Match, replacement string) string
- func (p *Pattern) SearchSnapshot(ctx context.Context, content piecetree.Snapshot, dst []Match, ...) ([]Match, error)
- func (p *Pattern) WordBoundary[T string | []byte](content T, start, end int) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LiteralArgs ¶
Types ¶
type Pattern ¶
type Pattern struct {
// contains filtered or unexported fields
}
func (*Pattern) DiskFilter ¶
DiskFilter returns a necessary substring for a match. The final scan of each candidate uses the same bytes for offsets, previews and the save digest. For regexps with no known mandatory substring every file is a candidate.
func (*Pattern) FindAll ¶
FindAll reuses caller-owned storage. A negative limit retains every match.
func (*Pattern) FindRange ¶
func (p *Pattern) FindRange[T string | []byte](content T, dst []Match, start, end, limit int, countAll bool) ([]Match, int)
FindRange keeps document-relative offsets and word/regexp boundary semantics. countAll counts matches beyond the storage limit without retaining them.
func (*Pattern) FindSnapshot ¶
func (p *Pattern) FindSnapshot(content piecetree.Snapshot, dst []Match, start, end, limit int) []Match
FindSnapshot searches immutable pieces without materializing the document. Regexp readers preserve whole-document assertion and submatch semantics.
func (*Pattern) LiteralMatches ¶
func (p *Pattern) LiteralMatches(ctx context.Context, source io.Reader, visit func(document, start, end int) error) error
LiteralMatches streams NUL-separated documents through one process. rg emits a one-based record number and a byte offset relative to the entire input.
func (*Pattern) Replace ¶
Replace applies the original ranges once, so inserted matches are never visited.
func (*Pattern) Replacement ¶
func (*Pattern) SearchSnapshot ¶
func (p *Pattern) SearchSnapshot(ctx context.Context, content piecetree.Snapshot, dst []Match, start, end, limit int) ([]Match, error)
SearchSnapshot reads the edited pieces directly. Regex replacements need capture offsets and whole-document assertions from the compiled pattern.