Regexp missing in default SearchConfig (search.ts)?

Hi, I think regexp is missing from the default SearchConfig which leads to it not being possible to set by default (despite including it in the config supplied to search()). If that is not a design choice do you want a PR for it?

Cheers!

Are you asking for an option that makes it so that regexp search is turned on by default?

I mean that regexp: fallback?.regexp ?? config.regexp seems to be missing here:

function defaultQuery(state: EditorState, fallback?: SearchQuery) {
  let sel = state.selection.main
  let selText = sel.empty || sel.to > sel.from + 100 ? "" : state.sliceDoc(sel.from, sel.to)
  if (fallback && !selText) return fallback
  let config = state.facet(searchConfigFacet)
  return new SearchQuery({
    search: (fallback?.literal ?? config.literal) ? selText : selText.replace(/\n/g, "\\n"),
    caseSensitive: fallback?.caseSensitive ?? config.caseSensitive,
    literal: fallback?.literal ?? config.literal,
    wholeWord: fallback?.wholeWord ?? config.wholeWord
  })
}  

Which has the effect that despite search({regexp: true}) being used to instantiate the extension regexp is not set when opening the search panel (regexp?: boolean also needs to be included in interface SearchConfig).

That’s not a bug, that’s just a feature that you made up but doesn’t exist, right?

I don’t know if that’s a design choice or not, that’s why I am asking. I understood this:

/// Add search state to the editor configuration, and optionally
/// configure the search extension.
/// ([`openSearchPanel`](#search.openSearchPanel) will automatically
/// enable this if it isn't already on).
export function search(config?: SearchConfig): Extension {
  return config ? [searchConfigFacet.of(config), searchExtensions] : searchExtensions
}

As the intent being that the user can configure the extension with specific default options? With the current implementation it seems “everything” in the dialog (top, caseSensitive, literal, wholeWord) can be configured except regexp, but that may be a design choice?

There’s no direct correspondence between that set of options and the query options—search config options have been added as needed, and this hadn’t come up before. This patch adds it.

Perfect, thanks!