-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Find and Replace for notebooks and text files #6159
Conversation
Thanks for making a pull request to JupyterLab! To try out this branch on binder, follow this link: |
packages/documentsearch/src/providers/notebooksearchprovider.ts
Outdated
Show resolved
Hide resolved
packages/documentsearch/src/providers/notebooksearchprovider.ts
Outdated
Show resolved
Hide resolved
packages/documentsearch/src/providers/codemirrorsearchprovider.ts
Outdated
Show resolved
Hide resolved
packages/documentsearch/src/providers/codemirrorsearchprovider.ts
Outdated
Show resolved
Hide resolved
packages/documentsearch/src/providers/codemirrorsearchprovider.ts
Outdated
Show resolved
Hide resolved
packages/documentsearch/src/providers/codemirrorsearchprovider.ts
Outdated
Show resolved
Hide resolved
To note: this makes a change to the public API of CodeMirrorEditor - setSelection and setSelections previously disallowed reverse selections (it would force all selections to have anchor = from and head = to). Now, these two functions will allow reverse selections to be set. |
Excellent, thank you again very much. Lots of people are really looking forward to this! |
The windows JS test suite has been failing on async timeouts, and seem unpredictable and unrelated to this PR. The linux JS suite is passing. I'll merge this. |
Fixes #6081
Adds find and replace functionality, searches as you type, and makes some CSS updates to the search box. This feature allows you to replace one at a time or replace all at once in a notebook or text file. Clicking "Replace" will replace the currently highlighted match with the text in the replace box. "Replace All" replaces... all matches. Each time you do an individual replace, it gets its own entry on the undo/redo stack in that codemirror instance. A replace all action creates only one entry on the undo/redo stack, but that is also per codemirror instance (so in the notebook, you have to hit undo in each cell where text was replaced to undo everything). This is a limitation of the current undo/redo stack on the notebook level that I've been told might be easier to fix in the near future.
This adds two functions and one property to the
ISearchProvider
interface. FunctionsreplaceCurrentMatch
andreplaceAllMatches
do what you'd expect. The new propertyisReadOnly
is meant to indicate whether or not the SearchProvider is providing a search over a read only widget. This was necessary for the CSV viewer, which is read only and is the third user of theISearchProvider
interface. WithisReadOnly
set totrue
, the toggle to expand the search box for replace is removed.Search as you type was added to ensure that results are always displayed before you're able to execute a replace.
GIF demo: