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

Bug 330743

Summary: [content assist] constructor completion overwrites in 'insert' mode
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: TextAssignee: Markus Keller <markus.kell.r>
Status: CLOSED WONTFIX QA Contact:
Severity: major    
Priority: P3 CC: daniel_megert, markus.kell.r
Version: 3.5   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Markus Keller CLA 2010-11-20 13:37:26 EST
N20101119-2000

Method completion wrongly overwrites text after the caret in Insert mode.

- reset Java content assist preferences to default
- start with this snippet:

	Process pmset = Runtime.getRuntime().exec("pmset -g pslog");
	pmset.getInputStream();

- put caret on the beginning of the second line
- type "new BuffIn"
- Ctrl+Space, Enter
=> result:   "new BufferedInputStream(|in|).getInputStream();"
=> expected: "new BufferedInputStream(|in|)pmset.getInputStream();"
( || marks the selection)
Comment 1 Markus Keller CLA 2012-02-29 19:03:02 EST
Still broken in master. I had almost the same code snippet as in comment 0.
Comment 2 Markus Keller CLA 2012-08-27 10:33:46 EDT
I hit this bug quite frequently. Sometimes, I don't realize immediately that constructor completion is broken and waste time trying to find out what happened.

Raising severity since the IDE must not eat my code.

class Main {
    public static void main(String[] args) {
        System.out.println(new StringBu|args[0]); // insert constructor at |
    }
}
Comment 3 Markus Keller CLA 2013-12-11 08:35:39 EST
Another use case:

import java.io.*;
public class Try {
    Reader open(File file) throws FileNotFoundException {
         return new BufferedReader|new FileReader(file);
    }
}

Delete '|', press Ctrl+Space, press Enter (or Ctrl+Enter). The keyword 'new' is overwritten, regardless of the Completion inserts/overwrites mode:

         return new BufferedReader(null) FileReader(file);
Comment 4 Eclipse Genie CLA 2020-03-08 17:03:28 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.