Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 376115

Summary: After modifying buffer, Replace changes the wrong text
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: EditorAssignee: libing wang <libingw>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: libingw
Version: 0.5   
Target Milestone: 0.5 RC1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2012-04-04 15:09:26 EDT
I20120403-2230

1. Open a file in the editor.
   (Ensure that 'Incremental find' and 'Show all' are checked)
2. Open the Find toolbar (Ctrl+F).
3. Type a query in the 'Find With' field.
   The occurrences will be highlighted. The next occurrence (after the caret) becomes active.
4. Add some characters to the buffer at an offset that precedes the next occurrence.
5. Type some text in the 'Replace With' field, then click 'Replace'.

I expected this to replace the next occurrence of the term. But instead it changes the next occurrence's old location (from before step 4). This means non-matching text gets modified, which is bad.

Note that the problem only happens the first time you use Replace after changing the buffer.
Comment 1 libing wang CLA 2012-06-05 17:24:54 EDT
fixed with http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=50f2cbb8413ae9dbdf5d3f215447d4bbabd5c0dd.

Now when you hit replace, we are always looking for the next occurrence of the search string from the caret position. If there is a selection we start from start position of the selection.
When you are replacing and find next in a chain, we always set the editor's selection to the range of next hit. So this replace policy makes sense.