Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 44789 - [find/replace] Dialog should not re-initialize find field when editor is activated
Summary: [find/replace] Dialog should not re-initialize find field when editor is acti...
Status: RESOLVED DUPLICATE of bug 6202
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P4 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-13 21:43 EDT by Michael Scharf CLA
Modified: 2004-05-12 11:12 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Scharf CLA 2003-10-13 21:43:03 EDT
I wanted to use regular exrpessions to replace some string in many files.

Suppose, I want to replace all 
  (\w+)\.printStackTrace\s*\(\s*\)
With
  my.package.Util.printStackTrace($1)

I search for
  (\w+)\.printStackTrace\s*\(\s*\)
Or maybe simply
   printStackTrace

Steps:
1. search the string with the search tool
2. jump to the first match
3. enter the regular expression and the replace string into the find dialog
4. replace all
5. jump to the next match
6. (anoying) because the replace dialog automatically fills in the current
   selection, I have to select my regular expression again in the dialog
7. goto step 4.

Proposal: have a setting to disable the automatic filling of the selection.
Comment 1 Dani Megert CLA 2003-10-14 12:33:51 EDT
>I wanted to use regular expressions to replace some string in many files.
This is not possible with the Find/Replace dialog except when you have the files
open and activate the editor one after each other.

Is step 5 correct? I cannot reproduce. Maybe you meant: jump to the next editor?
Comment 2 Michael Scharf CLA 2003-10-14 16:01:41 EDT
I do the "global replace" in 2 steps:

1. I use the normal string search dialog to find all matches 
   across files.
2. I use the "Show Next Match" button in the search view to
   navigate to the candidate files. In those files I use the
   Find/Replace dialog.

To see the effect, you have to:
1. open a Find dialog (and set the search string to something)
2. do a file search
3. hit the "Show Next Match"
4. set the focus into the editor (e.g. by clicking the title of
   the editor) 
--> the "Find" field in the find dialog changes to the selection of 
    the match


Maybe there is a better way to do "global replace".....


Comment 3 Dani Megert CLA 2003-10-15 04:43:12 EDT
>Maybe there is a better way to do "global replace".....
Yes there is but it does currently not allow you to use regex in replace string,
only in search string:
1. open the Search dialog and flip to the File search page
2. do the search
3. in the Search view select the matches you want to replace and from the
context menu select "Replace..." or "Replace Selected..."

There are feature requests to improve this (i.e. make it more prominent and
allow to replace all matches without asking).

I changed the summary of this bug since it is not regex specific. We do the
selection on purposes: this allows you to enter a replace string and immediately
replace the selection. This is the 80% behavior when you open the Find/Replace
dialog. Maybe we have to come up with a better strategy when the dialog is
already open.

Comment 4 Tom Hofmann CLA 2004-05-12 10:51:19 EDT
request to not autmatically fill the find expression is a dup of bug 6202.

*** This bug has been marked as a duplicate of 6202 ***
Comment 5 Carolyn MacLeod CLA 2004-05-12 11:12:37 EDT
I absolutely agree that populating the find field is "the 80% behavior 
*****WHEN YOU OPEN****** the Find/Replace dialog."

However, WHEN THE DIALOG IS ALREADY OPEN, I would argue that magically RE-
populating the find field is the 0% case. I actually disagree very strongly 
that anyone ever uses that 'feature' of the Find/Replace dialog. Correct me if 
I am wrong, with a concrete, useful, not contrived example, and I can probably 
be convinced that it is the 1% case. Because the find field can be repopulated 
with the selection at any time by simply typing ^F again, the automagic 
repopulation when switching editors is counter-intuitive and counter-
productive.