This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 271234

Summary: Find and Replace within Selection is inconsistent
Product: editor Reporter: CaptainStarbuck
Component: SearchAssignee: Milutin Kristofic <mkristofic>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 8.2   
Hardware: PC   
OS: Windows 8.1 x64   
Issue Type: DEFECT Exception Reporter:

Description CaptainStarbuck 2017-08-04 18:25:21 UTC
When using Ctrl+H to replace within the current selection, there is some condition that turns off the "active selection" flag, resulting in a global change. This has been reported in tickets since 2010 in PC, Linux, and Mac. I recently posted a test case in bug 207532 to verify that "find replace within selection" actually does work. Moving to another tab and doing a similar operation it insisted on doing global changes.

I will try to find/post a reproducible case given other obligations and time constraints. 
Possible triggers:
- Issue might be reset by closing the current tab and re-opening.
- Might be related to floating a tab.
- Currently only tested with PHP. Will try to test with Java and other file types.
- Might be related to doing a non-regex then changing to regex, or the second regex on some other condition, or selection after entry of find/replace text then clicking Replace All, or maybe related to whether selection starts at column 1 or ends at column 1 or beyond some other column...

People have been mentioning this issue for years, as an aside in find-related tickets, or as the topic of bug reports, and it doesn't look like there has been a dedicated effort to nail it - probably because it's inconsistent. I hope this ticket will drive toward focused testing and finally a fix.

STEPS:
 Highlight some text, ctrl+H, enter the search and replace terms as Regex, and then click Replace All to replace only within the current selection.

ACTUAL:
 SOMETIMES - All instances of the search pattern are replaced within the entire file. (Possibly within all open files? Need to verify.)

EXPECTED:
 Only replace within the selected area.



Product Version: NetBeans IDE 8.2 (Build 201609300101)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 2
Java: 1.8.0_141; Java HotSpot(TM) 64-Bit Server VM 25.141-b15
Runtime: Java(TM) SE Runtime Environment 1.8.0_141-b15
System: Windows 8.1 version 6.3 running on amd64; Cp1252; en_US (nb)

Refs:
Reports in bug 207532 request an enhancement to add find/replace in selection feature but this is invalid. The feature exists. But several people report the issue documented here, which is why I'm creating a separate ticket for a bug.

Exact same report on Mac in bug 268525

Slight relation to bug 175550

bug 118612

Bug 124504 closed in bulk cleanup

bug 217312