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

Find and Replace / Use Regular Expressions / Replace All: reference groups are NOT handled correctly #7503

Open
kuraga opened this issue Oct 30, 2024 · 3 comments
Labels
Milestone

Comments

@kuraga
Copy link

kuraga commented Oct 30, 2024

Description

On Find and Replace, using Regular Expressions, using Replace All,
reference groups are NOT handled correctly.

Reproduce

  1. Create a Jupyter notebook.
  2. Type in the first cell:
{
    'var1': 123,
    'var2': 456,
}
  1. Open the Find and Replace dialog.
  2. Roll out the Replace part.
  3. Click the Use Regular Expressions button.
  4. Type: : (\d+), at the Find input.
  5. Type: : $1+1, at the Replace input.
  6. Click the Replace All button.
  7. Expected cell content:
{
    'var1': 123+1,
    'var2': 456+1,
}
  1. Actual cell content:
{
    'var1': $1+1,
    'var2': $1+1,
}

At the same time, the Replace-button single replaces work as expected.

Expected behavior

On Find and Replace, using Regular Expressions, using Replace All,
reference groups are handled correctly.

Context

  • Operating System and version: Calculate Linux (Gentoo-based)
  • Browser and version: Chromium 129.0.6668.100, 64 bit
  • Jupyter Notebook version: 7.2.2
@kuraga kuraga added bug status:Needs Triage Applied to issues that need triage labels Oct 30, 2024
@krassowski
Copy link
Member

I can reproduce this. Using "Replace" button it works as expected, using "Replace All" it does not. FYI this is implemented in JupyterLab repo here:

https://github.com/jupyterlab/jupyterlab/blob/9cc6267d2e366390b861f725e5eca3ae04e86de9/packages/codemirror/src/searchprovider.ts#L399-L436

and replacing a single match is here:

https://github.com/jupyterlab/jupyterlab/blob/9cc6267d2e366390b861f725e5eca3ae04e86de9/packages/codemirror/src/searchprovider.ts#L330-L352

I do not immediately see where the error is. It would be good to also attempt reproducing in JupyterLab 4.3/Notebook 7.3 once these are released (soon).

@krassowski
Copy link
Member

Heads up: the upstream issue was closed (jupyterlab/jupyterlab#16925) and fixes will be backported to 4.3.x

@kuraga
Copy link
Author

kuraga commented Nov 12, 2024

Ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants