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 124504 - Replace all not constrained to selection
Summary: Replace all not constrained to selection
Status: RESOLVED WONTFIX
Alias: None
Product: editor
Classification: Unclassified
Component: Search (show other bugs)
Version: 6.x
Hardware: PC All
: P4 blocker (vote)
Assignee: issues@editor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-29 08:07 UTC by charliehnetbeans
Modified: 2009-11-02 10:59 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Scenario source (15.83 KB, text/plain)
2008-01-02 18:03 UTC, charliehnetbeans
Details

Note You need to log in before you can comment on or make changes to this bug.
Description charliehnetbeans 2007-12-29 08:07:23 UTC
Sometimes, when I do a Replace (Ctrl-h), when I have a block of text selected and have the "Search Selection" box
checked in the Replace dialog, then I click "Replace All", sometimes it replaces outside of the selected area as well as
inside the selected area. I think it always replaces below the selected area, never above the selected area. 

In one example,
"Match Case", "Whole Words", "Regular Expression", "Search Backwards" unchecked.
"Highlight Results", "Incremental Search", "Wrap Around", "Search Selection" checked.
Comment 1 Vitezslav Stejskal 2008-01-02 13:22:10 UTC
Please remember that the selection must contain multiple lines for this to work properly. If the selection does not span
multiple lines the search selection is not checked and is disabled and the selected text is used for the 'Find what'
field. This could be confusing in some situations.

If you are sure the checkbox is ticked and still the operation replaces text behind the selected area then it is a bug
of course. It would be helpful if you could find some reproducible scenario. Thanks a lot
Comment 2 charliehnetbeans 2008-01-02 18:03:26 UTC
Created attachment 54613 [details]
Scenario source
Comment 3 charliehnetbeans 2008-01-02 18:14:55 UTC
Using the attached CallList1.java.

Select lines 112 - 116 inclusive.

Ctrl-h

Find: import
Replace with: xxxx

match case, whole words, regular expression, search backwards - UNCHECKED
highlight results, wrap around, incremental search, search selection - CHECKED

Click "replace all"

Search for xxxx - will find many hits outside of the selection where the text used to be "import"

---------

Hmmm - first time I ran this scenario it replaced outside of selection (buggy behavior), 
second time it didn't (correct behavior). 
Third time - same selection, same checks and unchecks - it replaced outside the selection again (buggy behavior).

(After first and second trial, I undo, restoring the file to it's original state)
Comment 4 Vitezslav Stejskal 2008-01-03 11:07:06 UTC
Yep, I can see the defect now. The first time you try it works, but the next time it completely ignores the selection
for some reason. More precisely it starts replacing at the selection start, but does not stop at the selection end and
goes to the end of the document.

If you are using the default fonts & colors profile you should see the selected region painted with the light blue
background. The color is slightly different from the color for selecting text. So, when the Replace dialog is shown the
text region where it is supposed to search & replace has that light blue background. When I tried for the second time
(buggy behavior) there was no background color for the selected region. You could use this in the meantime as a clue for
knowing if the search boundary was really set or not.

Thanks for your help!
Comment 5 _ gtzabari 2008-02-10 18:29:38 UTC
Why is "Search Selection" grayed out if only one line is selected? This seems like bad usability to me. In fact, I
wasn't sure why this was happening and was about to file a bug report before running into this one.
Comment 6 Vitezslav Stejskal 2008-02-11 10:44:06 UTC
Well, if the selection does not span multiple lines (ie in other words only text within one line is selected) it is
unclear how the selection should be used. The two possibilities are:

1. the selected text is _what_ a user wants to search for
2. the selected text is _where_ a user wants to search

As we believe #1 is more commonly used and therefore it's how netbeans use the selection in this situation. Maybe we
could build up some more logic around this, but at the moment we only check if the selection spans several lines or not.
Comment 7 David Strupl 2009-03-31 15:49:57 UTC
Resolving all issues with milestone "future" as LATER. If you feel strongly that
it should be implemented please reopen and set the target milestone to "next".
Comment 8 Quality Engineering 2009-11-02 10:59:47 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX