Add test and regexpTest functions to SearchQuery config #18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "add-test-function-to-searchquery"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds
testandregexpTesttoSearchQuery'sconfig, which can be used to specify a customtestfunction forSearchCursorandRegExpCursor.See: https://discuss.codemirror.net/t/custom-test-function-for-searchquery-config/9323
These look very specific to your use case, and not very elegant in their interface. Would a single function (not split between regexp and regular matches), that passes the matched string, an editor state, and from/to positions, work for you? I guess you're trying to optimize by passing in the data structures that are locally available, but that feels like it leaks too much of the internal implementation, and needlessly complicates the signatures.
Yeah, this is just some minimal changes that would allow me to do the filtering I wanted to do, using the same signature as the test function used internally.
Yes, that should work. I do a regex test on the whole line (of the match) and use
toandfromfor my filtering.I've now updated the PR to use a single test function that is passed the matched string, state, and from/to positions like you suggested.
Thanks, that looks much better. I've merged this as
d55469959aThanks! Feels good to be back on the official
@codemirror/searchpackage, instead of a copied monstrosity :).Pull request closed