jupyterlab / jupyterlab

JupyterLab computational environment.
https://jupyterlab.readthedocs.io/
Other
13.82k stars 3.12k forks source link

Fix replace when replacement text matches source text multiple times #16258

Closed JasonWeill closed 1 week ago

JasonWeill commented 2 weeks ago

References

Fixes #16242.

Code changes

Advances to the next match when the replacement text matches the source text at least twice.

(This is a draft PR with tests created first.)

User-facing changes

After replacing a search term (e.g., foo) with replacement text that contains the search term multiple times (foofoofoo) the highlight advances to the next match after the replacement text, including if the next match is in a later cell.

Backwards-incompatible changes

None.

jupyterlab-probot[bot] commented 2 weeks ago

Thanks for making a pull request to jupyterlab! To try out this branch on binder, follow this link: Binder

JasonWeill commented 1 week ago

With Firefox and Chrome, I see the expected behavior when I replace the search text (e.g., test) with a replacement that matches the search text 0 times (foo), 1 time (tester), 2 times (testtest), and 3 times (testtesttest), but the UI tests in the pipeline fail reliably. Not sure what's causing this, but I'm promoting this from a draft to ready for review.

(Update: After a rebase, the 2x and 3x cases are not working again :( )

JasonWeill commented 1 week ago

The most recent commits fix the 0-match, 1-match, 2-match, and 3-match cases on my desktop.

JasonWeill commented 1 week ago

Still seeing unit test failures; I might have to test again after a rebase.

JasonWeill commented 1 week ago

All tests related to search and replace are now passing; this PR is now ready for review.