Closed rdpoor closed 4 years ago
I just ran into this; here's a screenshot showing the correct replacement in the Find and Replace preview and the wrong replacement in the confirmation dialog.
Reproduced in project replace. I was only using one regex group:
find: some_text_(.*)
replace: other_text_$1
results in the literal other_text_$1
in every instance of some_text_(.*)
in the project.
Also seeing the same as @christalee, the window displays the correct changes in all instances, so was a little surprised when I suddenly had lots of $1 literals in my code.
However, when trying the same in buffer find-replace, the result is interestingly that some_text_(.*)
is found, but when replace is pressed nothing changes and the panel is now showing not found.
$ atom --version
Atom : 1.43.0
Electron: 4.2.7
Chrome : 69.0.3497.128
Node : 10.11.0
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G3020
I came here to report the same bug. It's very annoying, particularly if you don't spot the bad result immediately.
Prerequisites
Description
A Project-level regex find/replace inserts literal
$1
,$2
, etc rather than the appropriate regex field.Steps to Reproduce
if (tstat_fvars()->curr_setpoint[HEAT_EN] > new_tptr->heat_limit) { tstat_fvars()->curr_setpoint[HEAT_EN] = new_tptr->heat_limit; }
tstat_fvars\(\)->curr_setpoint\[(.+?)\] = (.+?);
tstat_set_curr_setpoint($1, $2);
Find All
Expected behavior:
Before the substitution, foo.c contains:
if (tstat_fvars()->curr_setpoint[HEAT_EN] > new_tptr->heat_limit) { tstat_fvars()->curr_setpoint[HEAT_EN] = new_tptr->heat_limit; }
After the substitution, foo.c should contain:
if (tstat_fvars()->curr_setpoint[HEAT_EN] > new_tptr->heat_limit) { tstat_set_curr_setpoint(HEAT_EN, new_tptr->heat_limit); }
Actual behavior:
But instead, foo.c ends up with:
if (tstat_fvars()->curr_setpoint[HEAT_EN] > new_tptr->heat_limit) { tstat_set_curr_setpoint($1, $2); }
Reproduces how often:
Appears to be 100% reproducible.
Versions
`$ atom --version
Atom : 1.43.0 Electron: 4.2.7 Chrome : 69.0.3497.128 Node : 10.11.0
$ apm --version internal/child_process.js:357 throw errnoException(err, 'spawn'); ^ Error: spawn UNKNOWN at ChildProcess.spawn (internal/child_process.js:357:11) at spawn (child_process.js:528:9) at EventEmitter. (C:\Users\r\AppData\Local\atom\app-1.43.0\resources\app\apm\lib\apm-cli.js:169:17)
at process._tickCallback (internal/process/next_tick.js:61:11)
$ systeminfo
Host Name: NUC-10 OS Name: Microsoft Windows 10 Pro OS Version: 10.0.18362 N/A Build 18362 OS Manufacturer: Microsoft Corporation OS Configuration: Standalone Workstation OS Build Type: Multiprocessor Free Registered Owner: esnowden@nsa.gov (just kidding) Registered Organization: N/A Product ID: 00330-80000-00000-AA681 Original Install Date: 9/15/2019, 8:25:45 PM System Boot Time: 1/27/2020, 12:46:03 PM System Manufacturer: Intel(R) Client Systems System Model: NUC8i5BEK System Type: x64-based PC Processor(s): 1 Processor(s) Installed. 01: Intel64 Family 6 Model 142 Stepping 10 GenuineIntel ~2304 Mhz BIOS Version: Intel Corp. BECFL357.86A.0064.2019.0213.1122, 2/13/2019 Windows Directory: C:\WINDOWS System Directory: C:\WINDOWS\system32 Boot Device: \Device\HarddiskVolume2 System Locale: en-us;English (United States) Input Locale: en-us;English (United States) Time Zone: (UTC-08:00) Pacific Time (US & Canada) Total Physical Memory: 32,637 MB Available Physical Memory: 21,799 MB Virtual Memory: Max Size: 37,501 MB Virtual Memory: Available: 26,855 MB Virtual Memory: In Use: 10,646 MB Page File Location(s): C:\pagefile.sys Domain: WORKGROUP Logon Server: \NUC-10 Hotfix(s): 8 Hotfix(s) Installed.
Network Card(s): 4 NIC(s) Installed. 01: Hyper-V Virtual Ethernet Adapter Connection Name: vEthernet (Default Switch) DHCP Enabled: No IP address(es)
Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed. `
Additional Information
Note that an identical File-level regex find-replace works without trouble and does not manifiest the issue described here.