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 in Files: backreference in regex search and replace not working with newlines #80803

Closed
eduardZA opened this issue Sep 12, 2019 · 4 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s)

Comments

@eduardZA
Copy link

Issue Type: Bug

Create a text file and add the following:

this is the first line of the document.
this is the second one.

In the document, search for this:

(this is the first line)( of the document.)(\nthis is the second)( one.)

Replace the text with this:

$1$3

This gives the expected result.
Screenshot 2019-09-12 at 16 01 55
Screenshot 2019-09-12 at 16 02 06

Follow the exact same procedure with the Find in Files dialog. This works in the absence of newline characters:
Screenshot 2019-09-12 at 15 56 19

As soon as the search is extended to contain a multiline pattern, the backreferences are printed explicitly and not interpolated:
Screenshot 2019-09-12 at 16 01 09

These types of replacements definitely worked in version 1.29 with much more complicated replace patterns, even using optional groups.

The results are the same regardless of whether "search.usePCRE2": true is set (originally released in 1.29, but deprecated in 1.37).

VS Code version: Code 1.38.1 (b37e54c, 2019-09-11T13:31:32.854Z)
OS version: Darwin x64 18.7.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz (8 x 2200)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 3, 3, 2
Memory (System) 16.00GB (0.11GB free)
Process Argv -psn_0_548998
Screen Reader no
VM 0%
Extensions (14)
Extension Author (truncated) Version
vscode-css-formatter aes 1.0.1
shell-snippets cds 0.1.2
bracket-pair-colorizer Coe 1.0.61
scala dal 0.0.5
gitlens eam 9.9.3
terraform mau 1.4.0
rainbow-csv mec 1.3.1
ecdc mit 1.3.0
vscode-docker ms- 0.7.0
Go ms- 0.11.4
chef Pen 0.7.1
ruby reb 0.25.3
vscode-yaml red 0.5.2
HCL who 0.0.5
@elizabeth-dev
Copy link

Same here. Seems a duplicate of #80732, #80667, and #79924.

@KapitanOczywisty
Copy link
Contributor

KapitanOczywisty commented Sep 12, 2019

@ eduardZA Do you have the same behavior when there are multiple matches in single files?

Problem seems to be not present when 2 results shares any line.
image

@eduardZA
Copy link
Author

@KapitanOczywisty, quite right:

image

It would seem as if matches separated by newlines are the ones struggling.

@roblourens
Copy link
Member

Dupe of #80667

@roblourens roblourens added the *duplicate Issue identified as a duplicate of another issue(s) label Sep 15, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

5 participants