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 capture group/backreference inserts undefined instead of empty string #19740

Closed
calebmosher opened this issue Feb 2, 2017 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release editor-find Editor find operations important Issue identified as high-priority verified Verification succeeded

Comments

@calebmosher
Copy link

  • VSCode Version: 1.9.0
  • OS Version: OSX 10.11.6

Steps to Reproduce:

  1. Execute find/replace with regex.
  2. Using backreference replacements (e.g. $1, $2...), if the capture group did not capture anything, VS Code outputs "undefined" instead of the expected "" (empty string).

This just started happening after upgrading to 1.9.0 today (02/02/17) and was not doing this yesterday.

@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority labels Feb 3, 2017
@Tyriar
Copy link
Member

Tyriar commented Feb 3, 2017

@roblourens may be worth fixing for stability build?

@roblourens
Copy link
Member

I can't repro this. Can you give a specific example?

@sandy081?

@calebmosher
Copy link
Author

Steps to Reproduce:

  1. Open a blank new document.
  2. Type abcd.
  3. Bring up find (⌘F or Edit->Find)
  4. Click small arrow on the left of find modal to open replace module.
  5. Activate regex find (⌥⌘R or click [.*] icon)
  6. Type a(z)? in first input.
  7. Type a{$1} in second input.
  8. Execute replace (⇧⌘1 or click [c<-b] icon).

Actual behavior:
abcd is replaced by a{undefined}bcd

Expected Behavior:
abcd is replaced by a{}bcd


This is the way it works in Chrome and Node:

> 'abcd'.replace(/a(z)?/, 'a{$1}')
"a{}bcd"

...and the way it was working in VS Code before updating to 1.9.0 earlier today.

@roblourens
Copy link
Member

Ok, I see it. It doesn't repro with something like a(\d*) that I was trying.

@sandy081
Copy link
Member

sandy081 commented Feb 3, 2017

This could be due to the changes done by @alexandrudima #18111 ? Because I do not see this happening from Search view.

@sandy081 sandy081 added editor editor-find Editor find operations labels Feb 3, 2017
@joaomoreno joaomoreno added this to the January Recovery 2017 milestone Feb 3, 2017
@joaomoreno joaomoreno added the candidate Issue identified as probable candidate for fixing in the next release label Feb 3, 2017
@jrieken jrieken added the verified Verification succeeded label Feb 7, 2017
alexdima added a commit that referenced this issue Feb 7, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release editor-find Editor find operations important Issue identified as high-priority verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

7 participants