Skip to content
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

merged 11 commits into from Apr 11, 2019


Copy link

@aschlaep aschlaep commented Apr 2, 2019

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. Functions replaceCurrentMatch and replaceAllMatches do what you'd expect. The new property isReadOnly 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 the ISearchProvider interface. With isReadOnly set to true, 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:

Copy link

@jupyterlab-dev-mode jupyterlab-dev-mode bot commented Apr 2, 2019

Thanks for making a pull request to JupyterLab!

To try out this branch on binder, follow this link: Binder

@jasongrout jasongrout self-requested a review Apr 3, 2019
@tgeorgeux tgeorgeux self-assigned this Apr 3, 2019
@jasongrout jasongrout added this to the 1.0 milestone Apr 5, 2019
Copy link
Member Author

@aschlaep aschlaep commented Apr 10, 2019

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.

Copy link

@jasongrout jasongrout commented Apr 11, 2019

Excellent, thank you again very much. Lots of people are really looking forward to this!

Copy link

@jasongrout jasongrout commented Apr 11, 2019

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.

@jasongrout jasongrout merged commit f99c216 into jupyterlab:master Apr 11, 2019
7 of 9 checks passed
@jasongrout jasongrout mentioned this pull request Apr 12, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants