Object with methods useful for performing a search and both highlighting and replacing the matches.

Hierarchy

Properties

container: HTMLDivElement

Container that all the search results are appended to.

matches: [number, number][]

Array of positions of all the matches.

regex: RegExp

Current regex used for searching.

Methods

  • If a match is selected and it's different to the provided string, it's replaced, else the index of the closest match is returned. If there's no selected match, the index of the closest match is returned.

    Parameters

    • replacement: string

    Returns undefined | number

  • Replaces all search matches with the specified string.

    Parameters

    • replacement: string

      String to replace all matches with.

    • Optional selection: [number, number]

      Does nothing. Kept for backwards compatibility.

    Returns void

  • Unhides the search container and highlights all matches of the specified string in the editor.

    Parameters

    • str: string

      String to search for.

    • Optional caseSensitive: boolean

      Whether or not the search is case sensetive.

    • Optional wholeWord: boolean

      Whether or not matches must be surrounded by word boundries.

    • Optional useRegExp: boolean

      If true, special characters won't be escaped when creating the RegExp.

    • Optional selection: [number, number]

      Boundries to search between. If excluded, all the code is searched.

    • Optional filter: SearchFilter

      A function called for each match with the start and end positions of the match. If it returns false, the match won't be included.

    • Optional wholeWordBoundry: RegExp

      Pattern controlling the behavior of whole word search. Best left undefined unless you know what you're doing. Does nothing if wholeWord isn't set to true. Defaults to /[_\p{N}\p{L}]{2}/u.

    Returns string | void

    An error message if the RegExp was invalid.

  • Selects the match with the passed index and scrolls it into view with the specified scroll padding.

    Parameters

    • index: number
    • Optional scrollPadding: number

    Returns void

Generated using TypeDoc