code/editor/find/find-model
import { … } from 'zidane-ui/code/editor'ui/src/code/editor/find/find-model.ts
Functions#
diffLinesFunction#
fileLinesFunction#
findAllFunction#
Every match across parts in order, capped at MAX_FIND_MATCHES. capped says the cap cut the
search short.
function findAll(
parts: readonly { lines: readonly FindLine[]; part: string }[],
query: string,
opts: FindOptions,
): { capped: boolean; matches: LineMatch[] }Parameters
| Name | Type | Description |
|---|---|---|
| parts | readonly { lines: readonly FindLine[]; part: string }[] | The lines to search, grouped by the diff (or file) they belong to. |
| query | string | The literal string to look for. |
| opts | FindOptions | Case sensitivity. |
Returns
{ capped: boolean; matches: LineMatch[] }matchesInFunction#
Every occurrence of query in text, as UTF-16 offsets. Matches don't overlap; an empty
query matches nothing.
function matchesIn(
text: string,
query: string,
opts: FindOptions,
): { end: number; start: number }[]Parameters
| Name | Type | Description |
|---|---|---|
| text | string | The text to search, such as one line. |
| query | string | The literal string to look for (not a pattern). |
| opts | FindOptions | Case sensitivity. |
Returns
{ end: number; start: number }[]Constants#
MAX_FIND_MATCHESConstant#
Searching stops here: past it the count reads N+ and painting stays cheap.
const MAX_FIND_MATCHES = 5000Interfaces#
FindLineInterface#
One searchable line of a file or diff, numbered the way pierre numbers its rows.
interface FindLineProperties
| Name | Type | Description |
|---|---|---|
| line | number | 1-based line number on that side. |
| side | 'old' | 'new' | The diff side the line is on; |
| text | string | The line's text, without its line ending. |
FindOptionsInterface#
How a query matches text.
interface FindOptionsProperties
| Name | Type | Description |
|---|---|---|
| caseSensitive | boolean | Match letter case exactly; otherwise both sides are lowercased first. |
LineMatchInterface#
One match on one rendered line. side tells a diff's old line from its new one.
interface LineMatchProperties
| Name | Type | Description |
|---|---|---|
| end | number | UTF-16 offset in the line just past the match. |
| line | number | 1-based line number on that side, as pierre's |
| part | string | Which diff a match is in (a file key and the diff's index in it); |
| side | 'old' | 'new' | The diff side the line is on; always |
| start | number | UTF-16 offset in the line where the match starts. |