Add numMatches method to SearchQuery #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "num-results"
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?
Fixes the issue described here: https://github.com/codemirror/codemirror.next/issues/727
Although calculating the total number of matches for a given search query can be expensive and is calculated lazily, I believe it can be useful to expose this functionality for certain product use cases (for example, displaying the number of matches to the user in a custom search panel).
Let me know if this sounds reasonable and like something you would accept, otherwise I can close!
Is this not easy enough to do entirely in client code with the new
getCursormethod?oh yes, I totally missed that. looks like it's not even published yet. will give it a try when it is. thanks!
Oh, indeed, it wasn't published. I've tagged 0.19.9
FYI I think the return type of
getCursoris incorrect:github.com/codemirror/search@6fcc3247e1/src/search.ts (L112)The return type is
Iterator<{from: number, to: number}>but it actually returnsRegExpCursor | SearchCursor, both of which implementIteratorbut are strict supersets. This means TS complains when trying to access thevaluefield for example.How does that make it incorrect? Just use it like an iterator, which is the shared interface between those two types.
Pull request closed