SearchQuery

data class SearchQuery(val search: String = "", val caseSensitive: Boolean = false, val literal: Boolean = false, val regexp: Boolean = false, val replace: String = "", val wholeWord: Boolean = false, val test: (from: DocPos, to: DocPos, state: EditorState) -> Boolean? = null)

Represents a search query with options for how to match.

Parameters

search

The search string.

caseSensitive

Whether matching is case-sensitive.

literal

If true, treat search as a literal string even if regexp is true.

regexp

If true and literal is false, treat search as a regex pattern.

replace

The replacement string.

wholeWord

If true, only match whole words.

test

Optional filter callback. When set, only matches for which test(from, to, state) returns true are included.

Constructors

Link copied to clipboard
constructor(search: String = "", caseSensitive: Boolean = false, literal: Boolean = false, regexp: Boolean = false, replace: String = "", wholeWord: Boolean = false, test: (from: DocPos, to: DocPos, state: EditorState) -> Boolean? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val test: (from: DocPos, to: DocPos, state: EditorState) -> Boolean?
Link copied to clipboard

Whether this query is non-empty and (if regex) syntactically valid.

Link copied to clipboard

Functions

Link copied to clipboard

Expand replacement for a simple string match.

Expand replacement string, handling $1, $&, $$ substitutions for regex matches.

Link copied to clipboard
fun getCursor(state: EditorState, from: DocPos = DocPos.ZERO, to: DocPos = state.doc.endPos): Iterator<SearchMatch>

Get a cursor for this query over a given state.