Export togglePanel state effect #15
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "export-toggle-panel"
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?
We have an extension that's responsible for automatically highlighting matches when the search query changes, by watching for the
setSearchQueryeffect.When the search panel was open, this should scroll the match into view, but when the search panel wasn't open (i.e. it's opening now), the match should not be scrolled into view.
To achieve this, we need to check the
togglePaneleffect for a value oftrue(i.e. the panel is opening), which means thetogglePaneleffect needs to be exported from the@codemirror/searchpackage.We don't intend to dispatch the
togglePaneleffect, ascloseSearchPanelandopenSearchPanelalready exist for that purpose, so if you'd prefer to add a function that encapsulatestogglePanelinstead of exporting it, that would be fine too.Would a
searchPanelOpen(state)predicate work for you? That seems like it should address this case and be more generally applicable.I think
searchPanelOpen(state)would work, yes, assuming that iftogglePanel.of(true)andsetSearchQueryare effects on the same transaction then callingsearchPanelOpen(tr.state)would returnfalse, as thetogglePaneleffect hasn't been applied yet.No, the new state will have the panel open, so that'd return true.
searchPanelOpen(tr.startState)would return false though.Ok,
searchPanelOpen(tr.startState)sounds good - I assume you'll want to add that function?Added this in 6.1.0
Pull request closed