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

Bug 337156

Summary: [content assist] steals my semicolon when I press ; outside of linked mode
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: TextAssignee: Markus Keller <markus.kell.r>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: briancort, daniel_megert
Version: 3.7   
Target Milestone: 3.7 M6   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Fix daniel_megert: review+

Description Markus Keller CLA 2011-02-14 14:09:37 EST
N20110213-2000

package xy;
class Bug {
    void foo() {
        set
    }
    
    void setAnswer(boolean answer, int n) { }
    boolean getAnswer() {
        return true;
    }
}


- Have "Java Editor > Content Assist > Insert best guessed arguments" selected and "Java Editor > Typing > Auto-insert Semicolon" unchecked

- invoke content assist after "set"
- press Enter to accept first proposal
- press End
- press ;
=> line is "setAnswer(;|, 0)" where | is the caret

Expected: Semicolon should be inserted at end of line where the caret was.
Comment 1 Markus Keller CLA 2011-02-14 14:28:06 EST
Created attachment 188938 [details]
Fix

Dani please speak up if you don't like the fix.

I've removed an "if (key == ';')" check in the language-agnostic CompletionProposalPopup2 that was there for no good reason, and I changed the additional trigger character in ParameterGuesser from ';' to ',', which also fixes bug 154740.
Comment 2 Dani Megert CLA 2011-02-15 09:02:51 EST
*** Bug 154740 has been marked as a duplicate of this bug. ***
Comment 3 Dani Megert CLA 2011-02-15 09:05:57 EST
Comment on attachment 188938 [details]
Fix

+1 for the fix.
Comment 4 Markus Keller CLA 2011-02-15 09:12:50 EST
Fixed in HEAD.
Comment 5 Dani Megert CLA 2011-02-21 05:58:54 EST
Actually, the fix breaks an important scenario:
1. take example from comment 0 and remove the second argument from setAnswer
2. code complete after "set"
3. press ';'
==> semicolon replaces the selection instead of adding it at the end.
Comment 6 Markus Keller CLA 2011-02-21 10:36:23 EST
(In reply to comment #5)
Yeah, that's what you used to get for free, but it's actually another scenario that was broken. With "Auto-insert Semicolon" unchecked, typing ";" should just mean "replace the selection with a ;". And that's what we do in HEAD.

To get the semicolon at the end, you need to enable the preference.
Comment 7 Dani Megert CLA 2011-02-22 02:05:41 EST
(In reply to comment #6)
> (In reply to comment #5)
> Yeah, that's what you used to get for free, but it's actually another scenario
> that was broken. With "Auto-insert Semicolon" unchecked, typing ";" should just
> mean "replace the selection with a ;". And that's what we do in HEAD.
> 
> To get the semicolon at the end, you need to enable the preference.

Indeed. I'm so used that the semicolon is auto-inserted that I forgot about this in my new test workspace.